FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [November 2012 Threads] PIC32 Application using queue crashesPosted by Kevin on November 1, 2012 Hi everybody,
I am facing a problem with PIC32 port when I try to use queues. I got a simple application, only one task, one queue. There are correctly initialised (task and queue handles aren't null), vTaskStartScheduler() is called, then my task tries to receive a message from the queue with xQueueReceive().
I get stuck in vListInsert(), but :
1. My stack task doesn't overflow (I use method 2 for stack checking and vApplicationStackOverflowHook() is never called)
2. I don't think I have trouble with interrupts priorities : Kernell priority is 1, max interrupt priority is set to 4. Plus, I don't have used any other interrupts than those used for the kernell.
3. When xQueueReceived() is called, the scheduler is running (xSchedulerRunning = 1 and uxSchedulerSuspended = 0) but in vListInsert(), scheduler is suspended (is that ok ?). Actually it is suspended when calling vTaskSuspendAll in xQueueGenericReceive().
4. Queue has been initialised, no pending message.
Then, a bus exception is thrown (DBE). I have the same problem if I create a second task that put a message into the queue.
If it could help, I am using XC32 v1.11. I can reproduce the problem with MPLAB Sim and when I am debugging with a Digilent Cerebot MX7ck board with built-in licensed debugger.
RE: PIC32 Application using queue crashesPosted by Dave on November 1, 2012 As your application is so small, please post the code. Make sure to enclose it with the Codify Text tags (button just above the text entry box in the forum).
RE: PIC32 Application using queue crashesPosted by Kevin on November 2, 2012 - Main(): int main(void) { vSetupHardware();
Create_Ressources_OSTracing();
vTaskStartScheduler();
return 0; } - Create_Ressources_OSTracing(): ErrorCode_t Create_Ressources_OSTracing (void) { ErrorCode_t ErrorCode = {0}; #ifdef OS_TRACE // 1. Create Task if((ErrorCode.Code&ERRCODEMASK) == CODE_000_NO_ERROR) { if(xTaskCreate(_OS_Trace_TaskHandler, "RTOS Trace Task", STACKSIZE_OS_TRACE, NULL, PRIORITY_OS_TRACE, &TASK_OSTracing) != pdPASS) { ErrorCode.Code = LAYER_Service | TASKID_OSTrace | CODE_002_MEMORY_ALLOCATION_ERROR; } }
// 2. Create Message to Send Queue if((ErrorCode.Code&ERRCODEMASK) == CODE_000_NO_ERROR) { Q_OSTracing = xQueueCreate(MAX_MSG_Q_OS_TRACE, sizeof(OS_TRACE_Msg_t)); if(Q_OSTracing == NULL) { ErrorCode.Code = LAYER_Service | TASKID_OSTrace | CODE_002_MEMORY_ALLOCATION_ERROR; } else { #if __DEBUG vQueueAddToRegistry(Q_OSTracing, "OS Tracing Queue"); #endif } } #endif return ErrorCode; } - The task - _OS_Trace_TaskHandler(): void _OS_Trace_TaskHandler (void * pvTaskParam) { OS_TRACE_Msg_tTraceMsg; OS_TRACE_Time_tTraceTime;
vTaskDelayMs(2000);
while(1) { if(xQueueReceive(&Q_OSTracing, &TraceMsg, portMAX_DELAY) == pdPASS) { if(TraceMsg.DateFlag) { _OS_Trace_GetTime(&TraceTime); _OS_Trace_FormatTime(&TraceTime, &TraceMsg); }
_OS_Trace_LogTrace(&TraceMsg); } } } vTaskDelayMs() is a macro that calls vTaskDelay and converts parameter in ms to ticks with portTICK_RATE_MS.
RE: PIC32 Application using queue crashesPosted by Richard on November 2, 2012 I'm curious why you test if((ErrorCode.Code&ERRCODEMASK) == CODE_000_NO_ERROR) when ErrorCode is a local variable and just been initialised so can't hold any value other than 0, but that is probably not relevant. What is probably relevant is the following call: if(xQueueReceive(&Q_OSTracing, &TraceMsg, portMAX_DELAY) == pdPASS) You don't show the definition of Q_OSTracing, but I suspect you don't need the '&' in front of it. If you declare it as: xQueueHandle Q_OSTracing; ...and it the queue has been created, then you can read from it using: xQueueReceive(Q_OSTracing, &TraceMsg, portMAX_DELAY); As you are using portMAX_DELAY, you only need to test the return value if INCLUDE_vTaskSuspend is not set to 1 in FreeRTOSConfig.h. That is because if INCLUDE_vTaskSuspend is set to one portMAX_DELAY will act as an indefinite wait. Regards.
RE: PIC32 Application using queue crashesPosted by Kevin on November 2, 2012 “when ErrorCode is a local variable and just been initialised so can't hold any value other than 0, but that is probably not relevant.” Yes it is, actually it's more a "way" that I try to respect, I agree this test isn't usefull ;) “What is probably relevant is the following call: [...] You don't show the definition of Q_OSTracing, but I suspect you don't need the '&' in front of it. If you declare it as: xQueueHandle Q_OSTracing;” Exact ! I'm more familiar with EmbOS from Segger, in which queue type is a structure, not a handle, which is actually just a void pointer ... I made the same mistake when I wanted to put a message into the queue : if(xQueueIsQueueFullFromISR(Q_OSTracing) != pdFALSE) { xQueueSend(&Q_OSTracing, &TraceMsg, MS_TO_TICK(50)); } That's why I got troubles in sending messages too. “As you are using portMAX_DELAY, you only need to test the return value if INCLUDE_vTaskSuspend is not set to 1 in FreeRTOSConfig.h. That is because if INCLUDE_vTaskSuspend is set to one portMAX_DELAY will act as an indefinite wait.” Yes, my task is suspended. I will let the test because this task maybe be used with different configuration of FreeRTOS, it is some kind of generic method to trace OS and application events for a few different FreeRTOS based softwares. Anyway, thank you for your help !
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|