Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


FreeRTOS Queue + STM32F303 + IAR

Posted by serj86 on August 1, 2015

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?


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

Posted by rtel on August 1, 2015

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.


FreeRTOS Queue + STM32F303 + IAR

Posted by serj86 on August 1, 2015

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.

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists