cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS hangs on xQueueSend

LMorr.3
Senior II

My program hangs on xQueueSend call:

if (xQueueSend(msg_queueHandle, (void *)&msg, 10) != pdTRUE) {

When I step through the code, I see it reaches the xQueueGenericSend function but exits on the first line of that function where the following is called:

configASSERT( pxQueue );

Any ideas on why configASSERT would always exit the function?

8 REPLIES 8
hs2
Senior

Simply because the queue handle pxQueue is (still) NULL which usually means the queue wasn’t created before used. Hence the valuable assert catching this sort of programming error.

LMorr.3
Senior II

When I pause the debugger with no break-points, the cursor ends up on configASSERT(pxQueue) line of the xQueueGenericSend function. The pxQueue is not null.

hs2
Senior

Then just step into the code to see why it's stuck there and/or check how you did #define the configASSERT macro (in your FreeRTOSConfig.h).

LMorr.3
Senior II

I'm a bit further along.

The main issue I have now is I used CubeMX to configure a queue named msg_queueHandle and it is set in freertos.c. How do I get CubeMX to expose msg_queueHandle as global so that I can access it from my blink_led_task.c file? There is no freertos.h file created by CubeMX to include in blink_led_task.c.

hs2
Senior

Sorry - I don't use cube.

Pavel A.
Evangelist III

> How do I get CubeMX to expose msg_queueHandle as global 

If Cube does not generate it as static, it is already exposed as global.

Otherwise add a small function in user area of main.c, like:

QueueHandle_t get_my_queue() { return msg_queueHandle; }

May this be your biggest problem ;)

LMorr.3
Senior II

I tried setting CubeMX to generate the queue with both Dynamic and Static and still not showing as global scope. I'm confused as to why mx does not expose msg_queueHandle globally? I was hoping I could simply add the queue in MX and have it in the global scope.

I also tried the getter function you recommended and msg_queueHandle is still generating a compile error as undefined.

LMorr.3
Senior II

Sovled! I was able to get my code working by adding the following to blink_led_task.h file which was calling msg_queueHandle:

extern osMessageQueueId_t msg_queueHandle;

If I place code in a file outside of main.c than I add the declaration.