各位大哥:我在练习MC9S12XEP芯片,但是我在做中断程序的时候,始终不能正确的运行到中断处理程序,一中断就跑飞了,好像。那位大哥给指点一下阿。谢谢啦!附上程序: void main(void) { /* put your own code here */ int i=1000; IVBR = 0xff; /* interrupt vector base address at $ff00 */ S12X_SetInterruptPriority(0x47,RQST + 0x07);
DDRA=0xFF; //选择输入输出方向 DDRP=0x00; PIEP=0xff; //选择打开PP0中断 PIFP=0x00; //清中断标志 SetupXGATE(); EnableInterrupts; for(;;) { PORTA_PA3=1; for(i=20000;i>=0;i--){ } PORTA_PA3=0; for(i=20000;i>=0;i--){ } } /* wait forever */ /* please make sure that you never leave this function */ } //# pragma CODE_SEG DEFAULT #pragma NO_FRAME #pragma NO_ENTRY #pragma NO_EXIT #pragma CODE_SEG __NEAR_SEG NON_BANKED /* make sure this code is located in non banked */ interrupt 47 void ISR(void){ PIEP=0x00;//停中断 PIFP=0x00; //清中断标志 PORTA_PA2=!PORTA_PA2; PIEP=0xff;//开中断 }
|