AnsweredAssumed Answered

Demo: FreeRTOS on STM32F4 Discovery

Question asked by JimK on Jan 8, 2012
Latest reply on Mar 14, 2012 by bumpy
For all interested, I developed a free demo download.  The demo is a simple project which can be dropped into TrueSTUDIO.  Within a few minutes you should be able to have a full blown preemptive real-time operating system up and running on the Discovery board!

The demo uses some code from Thomas Kindler who sorted out how to get FreeRTOS running on the STM32F4 (this was no small matter when you add a FPU into the mix).

Here is a link to Thomas's work:
https://github.com/thomask77/FreeRTOS_ARM_CM4F

My FreeRTOS demo does the following:
       
  • Runs several tasks in parallel using a SysTick of 1000Hz.
       
  •    
  • USART2 is used in a debug task to send status message from any task simply by calling vDebugPrintf().    
             
    • Source code for a super simple printf function is provided to format nice debug messages.
    •        
    • A FreeRTOS queue is used to buffer the debug messages.  The debug task removes the characters and sends them out the uart port.
    •        
    • No uart interrupts are used in the debug task (didn't want to get in the way of the main tasks).
    •        
    • The debug task is run at a low OS priority.
             
    •    
       
  •    
  • TIM4 is setup to output a PWM single into the four LEDs around the MEMS motion sensor.    
             
    • A simple function call provides a way to quickly and easily set the LED illumination levels for any of the four LEDs.
             
    •    
       
  •    
  • One task reads the MEMS motion sensor every 15ms, averages the results, and updates the four LEDs around the sensor.    
             
    • The amount the board is tilted (as measured by the MEMS motion sensor) determines the LED brightness.
    •        
    • The LED illumination fades nice and smooth as the board is tilted.
             
    •    
       
My hope is that this demo provides a quick and easy way to get started with the STM32F4 Discovery board. 

Here are the links where you can find the code to download:

http://ph-elec.com/archives/stm32f4-freertos/

http://ph-elec.com/archives/freertos-demo-and-truestudio/


Outcomes