#include "..\TARGET\config.h"
//#define TASK_STK_SIZE 256
#define TASK_STK_SIZE 64
#define CR 0x0D
OS_STK TaskLEDStk [TASK_STK_SIZE];
OS_STK Taskuart[TASK_STK_SIZE];
void TaskStart(void );
void Task_LED(void *pdata);
void Taskuart0 (void *pdata);
uint32 i;
void delay(uint32 i)
{ /* Delay function */
uint32 n;
while(i>1)
{
for(n=65535;n>1;n--);
i--;
}
}
int main(void)
{
OSInit(); /* Initialize uC/OS-II */
TargetInit();
TaskStart();
// OSStart();
return 0;
}
void TaskStart (void)
{
OSTaskCreate(Task_LED, (void *)0, &TaskLEDStk [TASK_STK_SIZE - 1], 1);
OSTaskCreate(Taskuart0, (void *)0, &Taskuart [TASK_STK_SIZE - 1], 0);
OSStart();
}
void Task_LED (void *pdata)
{
//INT8U err;
pdata = pdata;
PINSEL2 = PINSEL2 & (~0x08); //P1[25-16]设置为GPIO
IO1DIR |= LED1 | LED2 | LED3; //设置IO口为输出口
IO1SET = LED1;
IO1SET = LED2;
IO1SET = LED3;
while(1)
{
IO1CLR = LED1;
IO1CLR = LED3;
delay(50);
//OSTimeDly(OS_TICKS_PER_SEC);//OS_TICKS_PER_SEC/2); //延时1/2秒
IO1SET = LED1;
IO1SET = LED3;
delay(50);
}
}
void uar_putchar (INT8U ch)
{
if (ch == '\n')
{
while (!(U0LSR & 0x20));
//OSTimeDly(1);
U1THR = CR; // output CR
}
while (!(U0LSR & 0x20));
delay(10);
U0THR = ch;
//delay(10);
}
#if OS_TASK_STAT_EN > 0
void Taskuart0 (void *pdata)
{
INT8U Tab[]={0X01,0X02,0X03,0X04,0XAA};
//INT8U Tab[]={"11111AA#"};
INT8U *p;
pdata = pdata;
while(1)
{
p=Tab;
while(*p!=0XAA)
{
uar_putchar(*p++);
}
if(((INT8U)OSCPUUsage)/10!=0)
uar_putchar(((INT8U)OSCPUUsage)/10+48);
// else
// uar_putchar(' ');
if(((INT8U)OSCPUUsage)%10!=0)
uar_putchar(((INT8U)OSCPUUsage)%10+48);
//else
// uar_putchar(' ');
//uar_putchar('%');
//uar_putchar('\n');
}
}
#endif
请问大家我建立的两个任务,为什么不可以同时运行(单个任务都很正常) |