As you maybe know, STM32F4 is Cortex M4 with DSP instructions. This allows you to make a FFT with a few simple steps. For that purpose, I have made an example, on how to create FFT with STM32F4.
When the ARM company issued Cortex-M4 core, it also published DSP libraries for mathematics and other stuff. And there are also FFT functions. When you’ve downloaded ST’s standard peripheral drivers, you also downloaded CMSIS (Cortex Microcontroller Software Interface Standard), which are designed for all Cortex-M4 processors from every company.
CMSIS libraries are also included in Keil uVision (5 and newest), you just need to enable them. Under “Manager Run-Time Environment” -> CMSIS select DSP. DSP or Digital Signal Processing is a library for “high mathematics” instructions, which are supported by Cortex-M4 with floating point unit.
Enable DSP library in Keil uVision
Fast Fourier Transform – FFT
Very fast about FFT. FFT or Fast Fourier Transform is an algorithm to convert time based signal into frequency domain. In other words, you are able to know from which sinus components is some signal created.
After I made a tutorial on how to use printf with STM32F4, I decided to make a library for printf and other functions that are able to output data to the stream. This library allows you to basically use unlimited different output streams, but just one can be use with printf at a time. You can use other output functions, like fprintf, which accepts stream pointer as parameter to know where to output data.
Output strings using printf or any other function, like fprintf, etc
Any function which is able to output data to the stream can be used
Basically unlimited output streams can be used
Version 1.1 – October 19, 2014
Added support to read from standard input (stdin) stream or user defined
To enable printf functionality, first you need to create a new __FILE struct. This struct is then called with FILE struct. It can have only one dummy parameter, but it has to be created, because you need pointer to this structure if you want to output characters to stream. If you need any control for this, you can create your own. I created my own below:
Custom __FILE struct
/* We need to implement own __FILE struct */
/* FILE struct is used from __FILE */
After that, we have to create a variable with FILE struct:
/* You need this if you want use printf */
/* Struct FILE is implemented in stdio.h */
Variable name __stdout is important. You can not use different name, otherwise printf will not work. Last thing we need to create is a function, that will be automatically called from printf and will actually print your charater by character to stream. Function has fixed name and can not be changed. Continue reading →
For library 39, I made a low power modes library. This allows you to simple put STM32F4 into SLEEP, STOP or STANDBY mode. Point of this modes is simple. You want decrease current on device. If you are working on battery project, this will be very helpful.
You can set current down to about 2uA with proper low power mode.
I will tell you only the highlights of all 3 power down modes in this post. For detailed informations, check ST’s manual here.
STM32F4 Power consumption image from ST
Enable SLEEP mode
Enable STOP mode
Enable STANDBY mode
You can also test, if system was reset because of wakeup from Standby mode.