初级会员
- 积分
- 166
- 金钱
- 166
- 注册时间
- 2019-12-27
- 在线时间
- 27 小时
|
void task1_task(void *p_arg)
{
OS_ERR err;
u8 task1_str[]="First task Running!";
while(1)
{
printf("\r\nèÎÎñ1:\r\n");
LCD_Fill(0,150,100,300,RED);
OSSemPend(&MY_SEM,0,OS_OPT_PEND_BLOCKING,0,&err); //ÇëÇóDÅoÅá¿
memcpy(share_resource,task1_str,sizeof(task1_str)); //Ïò12Ïí×êÔ′Çø¿½±′êy¾Y
delay_ms(200);
printf("%s\r\n",share_resource); //′®¿úêä3ö12Ïí×êÔ′Çøêy¾Y
OSSemPost (&MY_SEM,OS_OPT_POST_1,&err); //·¢ËíDÅoÅá¿
LED0=!LED0;
OSTimeDlyHMSM(0,0,2,0,OS_OPT_TIME_PERIODIC,&err); //Ñóê±1s
}
}
void task2_task(void *p_arg)
{
OS_ERR err;
u8 task2_str[]="Second task Running!";
while(1)
{
printf("\r\nèÎÎñ2:\r\n");
LCD_Fill(0,150,100,300,BLUE);
OSSemPend(&MY_SEM,0,OS_OPT_PEND_BLOCKING,0,&err); //ÇëÇóDÅoÅá¿
memcpy(share_resource,task2_str,sizeof(task2_str)); //Ïò12Ïí×êÔ′Çø¿½±′êy¾Y
delay_ms(200);
printf("%s\r\n",share_resource); //′®¿úêä3ö12Ïí×êÔ′Çøêy¾Y
OSSemPost (&MY_SEM,OS_OPT_POST_1,&err); //·¢ËíDÅoÅá¿
LED1=!LED1;
OSTimeDlyHMSM(0,0,2,0,OS_OPT_TIME_PERIODIC,&err); //Ñóê±1s
}
}
void task3_task(void *p_arg)
{
OS_ERR err;
u8 task3_str[]="Third task Running!";
while(1)
{
printf("\r\nèÎÎñ3:\r\n");
LCD_Fill(0,150,100,300,GREEN);
OSSemPend(&MY_SEM,0,OS_OPT_PEND_BLOCKING,0,&err); //ÇëÇóDÅoÅá¿
memcpy(share_resource,task3_str,sizeof(task3_str)); //Ïò12Ïí×êÔ′Çø¿½±′êy¾Y
delay_ms(200);
printf("%s\r\n",share_resource); //′®¿úêä3ö12Ïí×êÔ′Çøêy¾Y
OSSemPost (&MY_SEM,OS_OPT_POST_1,&err); //·¢ËíDÅoÅá¿
// LED1=!LED1;
OSTimeDlyHMSM(0,0,2,0,OS_OPT_TIME_PERIODIC,&err); //Ñóê±1s
}
}
任务123优先级分别是345!
创建三个任务在LCD同一区域显示颜色 试验结果是LCD按红绿蓝显示但是时间间隔并不是2秒而是红绿一闪而过只有绿色显示两秒!
为什么?
怎么解决??
|
|