Posts

Showing posts with the label STM32F7

Customizing the ADC Sample Rate

Image
So in the last post I talked about getting streaming data from an Analog/Digital Converter unit on the STM32F746. In that case I let the ADC run at a pretty high clock rate, based on the PCLK2 configuration and a single ADC prescaler.  Needless to say, the options for sample rate are pretty limited, even when you throw in the 8-setting "per-channel" delay option. So, what if you want to sample at a more arbitrary rate, or even change the sample rate after booting? One way is to switch from "Continuous" mode to triggered mode. Timer Triggered ADC So if you look closely at the ADC settings in CubeMX, you will see the "External Trigger Conversion Source" under the ADC_Regular_ConversionMode section. This allows you to specify a timer event that will initiate a conversion.  For this mode, we want to disable the Continuous mode of the ADC, leaving it in single conversion mode, so that each trigger event starts a single conversion. How Does It Work With DMA? Wh...

Double-Buffered DMA from ADC

Image
Analog Streaming Data Capture Overview If you want to do high-powered Analog to Digital Conversion in a microcontroller, the best way is to use two buffers and cycle between them, so you can be recording data into one buffer and processing the data already in the other buffer.  ST-micro's STM32F7 products, and others, make this possible. While the API functions are available to do this, as of this writing it isn't all packaged together so you can do it easily. Here is what I found when I went through the process. The STM32F746G Discovery board is capable of taking ADC samples at more than 1 million per second, so it could be useful as a low-bandwidth scope, and audio spectrum analyzer, and so on. Project Setup To sample ADC in streaming mode, start with a CubeMX project based on the Discovery board. I choose not to initialize all peripherals, and just add the ones I want, which seems simpler. I am using CubeIDE 1.5.1. Some basic setup: In System Core / CORTEX_M7, enable the Pre...