Skip to main content
Graduate II
April 13, 2022
Question

FreeRTOS hangs on xQueueSend

  • April 13, 2022
  • 8 replies
  • 2994 views

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?

    This topic has been closed for replies.

    8 replies

    Visitor II
    April 14, 2022

    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.3Author
    Graduate II
    April 14, 2022

    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.

    Visitor II
    April 14, 2022

    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.3Author
    Graduate II
    April 14, 2022

    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.

    Visitor II
    April 14, 2022

    Sorry - I don't use cube.

    Super User
    April 14, 2022

    > 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.3Author
    Graduate II
    April 14, 2022

    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.3Author
    Graduate II
    April 14, 2022

    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.