This article will explain how to get started with the recently released STM32F4-Discovery board using ChibiOS. This board is really cheap (below 20$) and is an excellent evaluation platform for the STMicroelectronics Hi-Performance & DSP STM32F4 family.
This board is impressive when compared to the cost.
ChibiOS offers an excellent support for the STM32F4 platform. The application demonstrates the use of the following components:
All drivers are “native” in order to minimize the memory footprint, the bulky ST library has not been used (but is supported).
The demo application samples two analog channels (AN11 and Temperature Sensor) using the ADC driver and modulates two PWM channels using the average of four samples per channel. The sampled data is also transmitted over the SPI bus (SPI1, CPOL=0, CPHA=0, 16bits frames, MSb first).
The PWM is programmed with a cycle of exactly one second, the ADC samples modulate the two output channels with a duty cycle between 0 and 100 percent. The PWM outputs are connected to the board green and blue LEDs so you don't need any instrument to see the output.
By pressing the user button the test suite is activated and the output is transmitted over the serial port 1 (38400-8-N-1).
The application demonstrates the following tasks:
The demo code can be previewed here.
Now let's connect the various parts:
The demo is located under
./demos/ARMCM4-STM32F407-DISCOVERY and can be compiled by simply giving the “make” command.
If you don't need to debug but just want to upload the code on the board you may use the ST Visual Programmer tool. Its use is very simple:
If you are using the IAR Workbench or Keil uVision you can flash and debug the STM32F4-Discovery directly from you IDE (select ST-Link as probe and configure it in SWD mode).
The demo should run immediately after loading, if not then try disconnecting and reconnecting the board USB cable in order to reset it (older versions of ST visual programmer do not run the program automatically).
You will see both user LEDs flashing with an one second period, the green LED duty cycle can be adjusted using the potentiometer, the blue LED duty cycle is determined by the temperature and is driven by the STM32 internal sensor.
Using a Logic Analyzer you can monitor the SPI output, the demo periodically transmits eight 16 bits words, each one representing a sample taken by the ADC.
By pressing the user button the OS will execute the test suite, you can capture the USART2 output using a terminal emulator in order to examine the test report and the benchmark results.
Now you have a complete working RTOS supporting the STM32F4, strip the test suite code from the Makefile (you won't need it) and start experimenting modifying the file main.c.