各位大神好,我利用UCOS中的信号量实现共享数据的读取然后打印至串口,但是一直没有调通,其中我的任务在mytask.c中,麻烦大家看看问题出在哪里了?谢谢。
#include "main.h"
unsigned char share_resource[30];
OS_STK Stk_TaskStartUp[TASK_STARTUP_STK_SIZE];
OS_STK Stk_Task1_TaskTCB[TASK1_TEST_STK_SIZE];
OS_STK Stk_Task2_TaskTCB[TASK2_TEST_STK_SIZE];
OS_STK Stk_Task_LED3[TASK_TEST_LED3_STK_SIZE];
OS_STK Stk_Task_LED4[TASK_TEST_LED4_STK_SIZE];
extern OS_EVENT *My_EVENT;
void Task_StartUp(void *pdata)
{
OS_CPU_SR cpu_sr;
OS_ENTER_CRITICAL();
My_EVENT=OSSemCreate(1);
OSTaskCreate(Task1_TaskTCB, (void *)0, &Stk_Task1_TaskTCB[TASK1_TEST_STK_SIZE-1], OS_USER_PRIO_GET(5));
OSTaskCreate(Task2_TaskTCB, (void *)0, &Stk_Task2_TaskTCB[TASK2_TEST_STK_SIZE-1], OS_USER_PRIO_GET(6));
OSTaskCreate(Task_LED2, (void *)0, &Stk_Task_LED3[TASK_TEST_LED3_STK_SIZE-1], OS_USER_PRIO_GET(7));
OSTaskCreate(Task_LED3, (void *)0, &Stk_Task_LED4[TASK_TEST_LED4_STK_SIZE-1], OS_USER_PRIO_GET(8));
OS_EXIT_CRITICAL();
// OSTaskDel(OS_USER_PRIO_GET(4));
}
void Task1_TaskTCB(void *pdata)
{
INT8U err;
unsigned char task1_str[]="First task Running!";
while(1)
{
printf("\r\n ÈÎÎñ1:\r\n");
OSSemPend(My_EVENT,0,&err);
printf("%s\r\n",err);
memcpy(share_resource,task1_str,sizeof(task1_str));
printf("%s\r\n",share_resource);
OSSemPost(My_EVENT);
GPIO_ToggleBits(LED1);
OSTimeDlyHMSM(0, 0, 0, 1000);
}
}
void Task2_TaskTCB(void *pdata)
{
INT8U err;
unsigned char task2_str[]="Second task Running!";
while(1)
{
printf("\r\ÈÎÎñ2:\r\n");
OSSemPend(My_EVENT,0,&err);
printf("%s\r\n",err);
memcpy(share_resource,task2_str,sizeof(task2_str));
printf("%s\r\n",share_resource);
OSSemPost(My_EVENT);
OSTimeDlyHMSM(0, 0, 0, 1000);
GPIO_ToggleBits(LED2);
}
}
void Task_LED2(void *pdata)
{
while(1)
{
OSTimeDlyHMSM(0, 0, 0, 400);
GPIO_ToggleBits(LED3);
}
}
void Task_LED3(void *pdata)
{
while(1)
{
OSTimeDlyHMSM(0, 0, 0, 400);
GPIO_ToggleBits(LED4);
}
}
[code]int main(void)
{
//³õʼ»¯°å×Ó
SysTick_Configuration();
BSP_GPIO_Configuration();
USART1_Configuration(19200);
NVIC_Configuration();
OSInit();
OSTaskCreate( Task_StartUp,
(void *) 0,
(OS_STK *)&Stk_TaskStartUp[TASK_STARTUP_STK_SIZE - 1],
(INT8U) OS_USER_PRIO_GET(4));
OSTimeSet(0);
OSStart();
return 0;
}
[/code] |