Quality RTOS & Embedded Software

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


Loading

generic UART example for STM32 using CubeMX HAL

Posted by loccd on December 25, 2017

Hello: I am self-teaching myself STM32 and FreeRTOS, and I am having difficulty finding examples for this stuff compared to the plethora of examples I was able to gather when learning AVR's and arduino-land. I am trying to make a base for myself to use whenever I start a new project, and I am getting stumped on how to effectively use a UART with the CubeMX HAL and FreeRTOS.

In 2009, someone asked this very question, and the founder of FreeRTOS made a suggestion: https://www.freertos.org/FreeRTOSSupportForumArchive/July2009/freertosBestwaytoimplementgenericUARTdrivers3321054.html "..an efficient way would be to have a DMA pass data to and from the UART and a circular buffer. Then have the DMA interrupt use a semaphore to unblock tasks when there is enough data to make it worth processing."

So my question: does someone have an example of this working, ideally with the CubeMX HAL? I have been reading about task notifications (which I can use, since CubeMX uses FreeRTOS v9.0), is there an example that does this with those instead of semaphores? My base code that I am trying to port from arduino land, uses a command parser that can accept messages of varying length, and I need to keep that functionality.

I apolgize in advance for the n00b question... it is hard for me to take everything I've learned thus far and start from a blank page, and example to learn from would help me greatly. Thank you in advance :)


generic UART example for STM32 using CubeMX HAL

Posted by rtel on December 26, 2017

Specifics of FIFOs and DMAs are chip specific as the hardware moves the data, so outside of the scope of FreeRTOS support. The following file provides a heavily commented example of how to use a stream buffer to send data from an ISR to a task using software https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Demo/Common/Minimal/StreamBufferInterrupt.c

You can look at the source code on the direct to task notification documentation pages to see how to signal a task from an interrupt using a notification. If you were using a DMA to move data then the ISR would be the DMA end interrupt: https://www.freertos.org/RTOSTaskNotificationAsCounting_Semaphore.html


generic UART example for STM32 using CubeMX HAL

Posted by loccd on December 27, 2017

THANK YOU.. that example is more or less exactly what I was looking for.


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


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner