boot.asm中的中断设置为:
org 1Ch ;GPIO Interrupt Vector
ljmp _APSoC_GPIO_ISR
reti
中断程序为:
void APSoC_GPIO_ISR(void)
{EN_1;CLK_0;WR_W;
UART_1_PutChar(0Xff); //如进入中断的话,发送0xff给电脑
}
主程序为:
void main()
{
UART_1_CmdReset();
// Initialize receiver/cmd buffer
UART_1_IntCntl(UART_1_ENABLE_RX_INT|UART_1_ENABLE_TX_INT);
// Enable RX&TX interrupts
UART_1_Start(0x00); // Enable UART
INT_MSK0&=~INT_MSK0_GPIO;
M8C_EnableIntMask(INT_MSK0,INT_MSK0_GPIO);
M8C_EnableGInt ; // Turn on interrupts
cmd=0xe2;
UART_1_PutChar(0Xee);//发送0xee给电脑,表示初始化完毕
while(1)
{
CLK_0;
asm("nop");asm("nop");
asm("nop");asm("nop");
asm("nop");asm("nop");
asm("nop");asm("nop");
asm("nop");asm("nop");
asm("nop");asm("nop");
asm("nop");asm("nop");
asm("nop");asm("nop");
CLK_1;
} |