Quality RTOS & Embedded Software

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




Loading

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?

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

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.

Regards.


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) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS