FreeRTOS Queue + STM32F303 + IAR

Hi ! I use FreeRTOS 7.6.0 generated by CubeMX 4.9.0 with STM32F303 MCU (ARM CM4F) + IAR 6.50 Compiler. I send sensor L3DG20Data struct to queue in timer callback function and try to read it in L3GD20Thread. After receive from queue, in gyrorawdata struct L3GD20AXISZ variable is always 0. iar debugger watch Another two variables in struct transmitted correctly. What can be wrong there? Code:
typedef struct { i16t L3GD20AXISX; i16t L3GD20AXISY; i16t L3GD20AXISZ; } AxesRawt; osMessageQId GyroRawDataQueueHandle; osTimerId GyroTimerHandle; … void CallbackGyroTimer(void const * argument); static void L3GD20_Thread(void const * argument); … osTimerDef(GyroTimer, CallbackGyroTimer); GyroTimerHandle = osTimerCreate(osTimer(GyroTimer), osTimerPeriodic, NULL); osMessageQDef(GyroRawDataQueue, 16, AxesRaw_t); GyroRawDataQueueHandle = osMessageCreate(osMessageQ(GyroRawDataQueue), NULL); … static void L3GD20Thread(void const * argument) { AxesRawt gyrorawdata; for(;;) {
if( GyroRawDataQueueHandle != 0 ) {
xQueueReceive( GyroRawDataQueueHandle, &( gyro_raw_data ), ( portTickType ) 10 );
}
} } void CallbackGyroTimer(void const * argument) { AxesRawt L3DG20Data;
L3GD20GetAngRateRaw(&hspi1, &L3DG20Data); xQueueSendToBack(GyroRawDataQueueHandle, ( void * ) &L3DG20_Data, ( portTickType ) 0); }

FreeRTOS Queue + STM32F303 + IAR

You are declaring an AxedRawt structure on the stack, filling it with data, then using xQueueSendToBack() to copy the structure into the queue – that should be fine provided the queue was created so each space in the queue can hold an AxesRawt structure. However you are creating the queue using a call to GyroRawDataQueueHandle(), and I have no idea what that is doing as it is not a FreeRTOS function. Can you try using xQueueCreate(), so I can see how the queue is being created, as then if you still have a problem I will be able to advise if the queue is being created correctly for how it is being used. Regards.

FreeRTOS Queue + STM32F303 + IAR

Thank you for reply. In fact, it’s CubeMX bug. osMessageCreate() always give a 4bytes queue: stm forum If I use xQueueCreate() instead osMessageCreate() (API generated by CubeMX) all data transmitted correctly.