Getting Started With STM32 and Nucleo Part 4-Working with ADC and DMA
2019-09-30 | By Maker.io Staff
As we continue the series with STM32, let’s take a look at how to use the analog-to-digital converter (ADC). At first, we set up a single conversion that samples the voltage from a potentiometer and transmits the raw value over UART. We can then read this information on a serial terminal.
We run into problems, however, when we want to sample analog voltages at a much faster rate. So, we introduce the concept of direct memory access (DMA) to help pipe data from the ADC (or any other peripheral) to memory.
We can also use the DMA controller the other way, too. We start by showing an example of reading a large buffer of test data out over UART via DMA. From there, we build a quick demo of filling a circular buffer with ADC readings with the DMA controller. We’ll simply peek at the buffer contents in the STM32CubeIDE debugger to show how the DMA can act without CPU intervention.
Related Items
Related Projects
- Getting Started with STM32 - Introduction to STM32CubeIDE
- Getting Started with STM32 - I2C Example
- Getting Started with STM32 - Introduction to FreeRTOS
- Getting Started with STM32 - Working with ADC and DMA
Related Videos
Additional Resources
Download STM32CubeIDE: https://www.st.com/en/development-tools/stm32cubeide.html
STM32 HAL documentation (click on family from graphic and then Resources tab): https://www.st.com/en/embedded-software/stm32cube-mcu-mpu-packages.html
FreeRTOS documentation: https://www.freertos.org/
CMSIS-RTOS documentation: http://www.keil.com/pack/doc/CMSIS/RTOS2/html/index.html
Recommended Reading
- Getting Started with STM32 and Nucleo Part 1: Introduction to STM32CubeIDE and Blinky
- Getting Started with STM32 and Nucleo Part 2: How to Use I2C to Read Temperature Sensor TMP102
- Getting Started with STM32 and Nucleo Part 3: How to Run Multiple Threads with CMSIS-RTOS Interface
- Getting Started with STM32 - How to Use SPI
- Getting Started with STM32 - Timers and Timer Interrupts