写了两个任务,进入中断后程序有时到未定义指令,有时取数据中止。不知道什么原因,望大虾赐教。 一般开中断就会到数据中止。 中断句柄也添加了。 void Task0(void *pdata) { pdata = pdata; TargetInit (); Sem0 = OSSemCreate(0); PINSEL0 = 0x20000000; PINSEL1 = 0x00000000; PINSEL2 = PINSEL2 & (~0x08); EXTMODE = EXTMODE | 0x00; EXTPOLAR = EXTPOLAR & 0x0D; IO0DIR |= ((SLEEP)|(SC1)|(SC2)|(SDATA)|(DRDY)); IO1DIR |= CAL; IO0SET = SLEEP; IO0CLR = (SC1|SC2); IO1CLR = CAL; IO0DIR |= (SCLK|CS); OSTaskCreate (Task1,(void *)0, &Task1Stk[Task1StkSize - 1], 3); OSTaskDel(OS_PRIO_SELF); }
void Task1(void *pdata) { uint8 err; pdata = pdata; OSSemPend(Sem0, 0, &err); OS_ENTER_CRITICAL(); AD(); OS_EXIT_CRITICAL(); OSTimeDly(OS_TICKS_PER_SEC); }
void AD() { uint8 i; { IO0CLR = CS; IO0CLR = SCLK; for(i=0;i<20;i++) { IO0SET = SCLK; da = (IO0PIN>>3)&0x01; data = data|(da<<(19-i)); IO0CLR = SCLK; } IO0SET = CS; } }
void EINT1_Exception(void) { OS_ENTER_CRITICAL(); EXTINT = 0x02; VICVectAddr = 0; // 通知中断控制器中断结束 OS_EXIT_CRITICAL(); OSSemPost(Sem0); /* 通知采样任务 */ }
|