AnsweredAssumed Answered

Question about lightweight message queue:

Question asked by David Cooper on Jan 6, 2016
Latest reply on Feb 5, 2016 by David Cooper

I am trying to use _lwmsgq_init(location, num_messages, msg_size) to setup a message queue.

In this case I only need the queue to hold one message at a time and the messages may be a 100+ bytes.


I am using the following to setup the queue:


#define UARTQ_NUM_MESSAGES      1

#define UARTQ_MSG_SIZE                50        //In uint32s, allow for 200 byte messages

#define UARTQ_SIZE                          ((sizeof(LWMSGQ_STRUCT)/sizeof(_mqx_max_type)) + (UARTQ_NUM_MESSAGES * UARTQ_MSG_SIZE))


uint32_t g_uart_tx_msgq[UARTQ_SIZE];


result = _lwmsgq_init((void*)g_uart_tx_msgq, UARTQ_NUM_MESSAGES, UARTQ_MSG_SIZE);


I seem to have some confusion around the msg_size parameter.


If I use the code above code, it does not work.  After receiving a message from the queue the code ends up in the __boot_exception() while(1).


If I set UARTQ_MSG_SIZE to some smaller number (<= 25) and simply allocate the message queue as uint32_t g_uart_tx_msgq[1000], the code runs as expected for messages much larger than 8 bytes.


Is there a limit on the message size for lightweight message queues, or does anyone have other insight into what I am seeing.