开发环境:ads1.2+H-JTAG+H-FLASHER 程序有下面的结构:
flag=0; //开启一个定时器和中断; while(flag!=1) { 代码 }
//定时器中断服务程序 flag=1; 现在遇到的问题是: 刚开始的时候,程序能停在While处等中断,然后中断产生了,flag=1了,但是while循环始终不退出,这个是什么问题?是我调试的配置还是编译器?请大家一定要帮我啊.谢谢了!
extern uint8 g125mstimer;
void __irq IRQ_Timer0(void) { uint16 i; uint16 tempLength; uint32 u32Bak; uint8 u8TempT0IR; T0TCR = 0; //停止定时器 u32Bak = VICIntEnable; VICIntEnClr = (1<<4)|(1<<5)|(1<<6)|(1<<7); //禁止其他中断 u8TempT0IR = T0IR;
FeedDog(); if((u8TempT0IR & 0X01) == 0X01) {
} if((u8TempT0IR & 0X02) == 0X02) { } if((u8TempT0IR & 0X04) == 0X04) { FeedDog(); Timer125msDisable(); g125mstimer=1; } if((u8TempT0IR & 0X08) == 0X08) { } VICIntEnable = u32Bak; //使能其他中断 VICVectAddr = 0X00; T0TCR = 0X01; }
void Timer125msEnable(void) { T0IR = 0X04; T0MR2 = T0TC + Fpclk/8; T0MCR |= (1<<6); FeedDog(); } void Timer125msDisable(void) { T0IR = 0X04; T0MCR &= ~(0X07<<6); FeedDog(); }
void find_sever() { uint8 i,j; uint8 ccode[7]={0x00,0x03,0x1E,0xC2,0x00,0x09,0x14}; uint16 ReceiveFrameLength = 0; uint8* ReceiveFrame; //收到帧的存储区 for(i=0;i<32;i++) { gRunPara.ucMeters=0; } while(ccode[0]!=i) { FeedDog(); i=0; ModBus_conv(ccode,7); UART0_SendFrame(&InBuffer[32],17); g125mstimer=0; Timer125msEnable(); while(!g125mstimer) { ;//处理的代码 }//end while if(g125mstimer==1) { ccode[0]++; ccode[6]--; } }//end while return ; } |