#define TSK_STK_SIZE 512
#define START_PRI 0
#define SERIAL_PRI 15
#define SEND_PRI 16
#define LIGHT_PRI 20
unsigned char STARTStk[TSK_STK_SIZE];
unsigned char LIGHTStk[TSK_STK_SIZE];
//char start_cnt=0,flash=0;
void light(void)
{
while(1){
P3^=0x0;
OSTimeDly(100);
}
}
void start_task(void)
{
EA=1;//OS_EXIT_CRITICAL();
OSTaskCreate(light,(void *)0,&LIGHTStk[TSK_STK_SIZE-1],LIGHT_PRI);
while(1){
//watchdog=0x1e;
//watchdog=0xe1;
OSTimeDly(30);
}
}
void main(void)
{
OSInit(); /* uCos init and also enables interrupts*/
EA=0;
InitTimer0();
// InitSerial();
// InitSerialBuffer();
OSTaskCreate(start_task,(void *)0,(void *)&STARTStk[TSK_STK_SIZE-
1],START_PRI);
OSStart(); /* Starts uCos and never returns to main */
}
//os_cpu_c.c初始化定时器0
void InitTimer0(void) reentrant
{
TMOD=TMOD&0xF0;
TMOD=TMOD|0x01; //模式1(16位定时器),仅受TR0控制
TH0=0x0B1; //定义Tick=50次/秒(即0.02秒/次)
TL0=0x0E0; //OS_CPU_A.ASM 和 OS_TICKS_PER_SEC
ET0=1; //允许T0中断
TR0=1;
}