最近碰到个怪问题..在UCOS中.我的一个电机控制任务.如果用定时器来产生 输出脉冲.运行10多分钟就会产生 data abort interrupt.. 如果用OSTimeDly(1);延时产生,,就不会,,定时器 时发一个消息.. 电机控制任务是等待消息,,..怪,, 下面是部分程序: void MotorCtrolTask(void *pdata) { //INT8U Error; INT8U i=0; pdata = pdata; MotorInit(); while(1) { //OSSemPend(MotorRunSem,0,&Error); /*µÈ´ýmotor out enable ÐźÅÁ¿ */ OSTimeDly(1); if(MotorStatus == STOP) { MotorStatus = INCREASE; } else { MOTORCLK_1; for(i=0;i<30;i++); switch(MotorStatus) { case INCREASE: MotorIncreaseRate++; if(MotorIncreaseRate>MOTORRATE) { MotorIncreaseRate = 0; MotorStartStep++; if(MotorStartStep>=STARTSTEP) { MotorStatus = RUN; MotorStartStep = STARTSTEP; } MotorStartStopControl(MotorStartStep); } break; case DECREASE: MotorIncreaseRate++; if(MotorIncreaseRate>MOTORRATE) { MotorIncreaseRate = 0; if(MotorStartStep>0) { MotorStartStep--; MotorStartStopControl(MotorStartStep); } else { MotorStatus = STOP; MOTORRESET_0; MOTORRESET_1; MOTORCLK_0; } } break; default: break; } OSTimeDly(1); MOTORCLK_0; } } } //---------------------------------------------------------------
void Timer1_Exception(void) { T1IR = 0x01; VICVectAddr = 0; //interrupt close ֪ͨÖжϿØÖÆÆ÷ÖжϽáÊø OSSemPost(MotorRunSem); } |