AnsweredAssumed Answered

Message Queue usage

Question asked by Stepan Podhorsky on May 25, 2017

Hello all,


I have problems with Message Queue in CMSIS-RTOS. I have following code

for putting C structures onto the Message Queue

BOOL put_program_chunk(main_controller_req_t req){


main_controller_req_t *p_req;


BOOL retval;

BOOL no_memory = FALSE;


osStatus status;

uint8_t tmp;


// allocate memory in pool

p_req = (main_controller_req_t *)osPoolAlloc(flash_pool);


#ifdef APP_DEBUG

if(p_req == NULL){

   printf("No more space in flash pool.\r\n");




if(p_req != NULL){

*p_req = req;


// insert the prepared request into the transmission queue

// osOK = 0x0

if(!osMutexWait(flash_queue_mutex, osWaitForever)){

   // put the message into the queue

   // wait 5 ms?

   status = osMessagePut(flash_queue, (uint32_t)(p_req), 5);


   if(status == osOK){

      tmp = 1;


      tmp = 0;




   no_memory = TRUE;




   retval = FALSE;


   retval = TRUE;



return retval;



As soon as I try to call the osMessagePut, the program stick somewhere in the osMessagePut

function and the function never returns any value. The Message queue is shared by two tasks.

One is a producer (with priority equal osPriorityLow) and the second one is a consumer

(with priority equal osPriorityAboveNormal). Producing task is processed each 100 ms and

consuming task each 20 ms. Can anybody give me any advice what I have been doing wrong?

Thanks in advance for any suggestions.