新手入门
- 积分
- 10
- 金钱
- 10
- 注册时间
- 2020-3-4
- 在线时间
- 3 小时
|
2金钱
FreeRtos目前已经移植成功,任务切换和消息也正常。
但是正式运用到项目上时,发现诡异的现象,运行其中一个任务的xQueueReceive就进HardFault_Handler了。
目前代码已经被最精简如下。下面的“double val = 0.0;”代码行一旦屏蔽,运行就正常了。调了两天都没结果,望大侠帮助。
xQueueHandle q1;
xQueueHandle q2;
xQueueHandle q3;
void WorkTask_Work1()
{
int xResult;
uint8 msg1 = FALSE;
while(1)
{
xResult = xQueueReceive( q1, &msg1, 200 );
if(xResult == pdPASS)
{
double val = 0.0; //这一行注释掉,程序运行就正常了,奇怪?!
vTaskDelay(10);
}
}
}
void WorkTask_Work2(void)
{
int xResult;
uint8 msg1, msg2= FALSE;
while(1)
{
xResult = xQueueReceive( q2, &msg1, 200 );
if(xResult == pdPASS)
{
}
xResult = xQueueReceive( q3, &msg2, 200 );
if(xResult == pdPASS)
{
}
}
}
void WorkTask_Test(void)
{
WorkTask_Reset();
q1 = xQueueCreate(1, sizeof(uint8));
q2 = xQueueCreate(1, sizeof(uint8));
q3 = xQueueCreate(1, sizeof(uint8));
xTaskCreate((pdTASK_CODE)WorkTask_Work1, "WorkTask_Work1", 1024, NULL, 2, NULL);
xTaskCreate((pdTASK_CODE)WorkTask_Work2, "WorkTask_Work2", 1024, NULL, 2, NULL);
vTaskStartScheduler();
while(1);
}
|
|