#include"..\inc\44b.h" #include"..\inc\DEF.h" #include"..\inc\44blib.h" void delay(int t); void EINT4567_INIT(void); void __irq Eint4567(void); /************************************************************/ // eint4567 init program /************************************************************/ void EINT4567_INIT(void) { rPCONG=0xffff;//使G口工作在外部中断功能 rPUPG=0x00;//使上拉电阻使能 rINTCON=0x05; rINTMOD=0x00; rINTMSK=~(BIT_GLOBAL|BIT_EINT4567); } volatile char which_int=0; void Test_Eint() { Uart_Init(0,115200); Uart_Select(0); EINT4567_INIT(); pISR_EINT4567=(unsigned)Eint4567; Uart_Printf( "...this is my first test about external interrupt\n" "****************************************************\n" "please select the trigger style:\n" " 1:下降沿触发方式;\n" " 2:上升沿触发方式;\n" " 3:双沿触发方式;\n" " 4:低电平触发方式;\n" " 5:高电平触发方式;\n" "****************************************************\n" ); switch(Uart_Getch()) { case '1': Uart_Printf("你选择的是下降沿触发方式\n"); rEXTINT="0x22222222"; break; case '2': Uart_Printf("你选择的是上升沿触发方式\n"); rEXTINT="0x44444444"; break; case '3': Uart_Printf("你选择的是双沿触发方式\n"); rEXTINT="0x77777777"; break; case '4': Uart_Printf("你选择的是低电平触发方式\n"); rEXTINT="0x00000000"; break; case '5': Uart_Printf("你选择的是高电平触发方式\n"); rEXTINT="0x11111111"; break; default: return; } Uart_Printf("请您按下相应键进入测试中断!\n"); while(!which_int); switch(which_int) { case 1: Uart_Printf("外部中断4中断发生\n"); break; case 2: Uart_Printf("外部中断5中断发生\n"); break; case 4: Uart_Printf("外部中断6中断发生\n"); break; case 8: Uart_Printf("外部中断7中断发生\n"); break; } rINTMSK=BIT_GLOBAL; which_int=0; rINTCON=0x5; } void __irq Eint4567(void) { which_int=rEXTINTPND; rEXTINTPND="0x0f"; rI_ISPC=BIT_EINT4567; delay(100); } void delay(int t) { int i,j; for(i=0;i<t;i++) for(j=0;j<1000;j++); } void Main(void) { //while(1) // { Test_Eint(); // } } 程序进不去中断服务程序,希望大家多帮忙啊,谢谢 |