Posts

Showing posts from January, 2021

Basic Scan-Mode A/D DMA (STM32H743)

Image
A/D in Scan Mode using DMA Overview I wanted to setup a simple scan-mode DMA on my STM32H743ZI2 Nucleo, for a v-drum project where I want to sample about 6 different analog inputs at 10 KHz. It turns out it is pretty easy to setup, but there are a few pitfalls I ran into that can save you considerable headache. Project Setup Start with a new project in CubeMX based on the H743ZI2 Nucleo. 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 Prefetch and Caches  In Connectivity, set USART3 to Asynchronous mode.  By default it connects to PD8 and PD9, which sets up a serial connection via the ST-Link USB debug port.  The default baud rate is 115200. Then setup clocking: In the Clock Configuration tab, set PLL Source to HSI and set DIVM1 to /8 and DIVN1 to 120 and leave DIVP1 at /2.  Set the HPRE Prescaler to /2 and set the DxPREn dividers for the ...

FFT Analysis using CMSIS DSP Library

Image
FFT Analysis Many times, once you've captured a data stream from A/D or some other means, the next question is what is the frequency content of it? Generally, that means you have to use a Fast Fourier Transform to view the signal data in the frequency domain. There's a lot to signal analysis that I'm not going into here.  For a better coverage of that, I recommand LabKitty . This blog is just going to walk through the basic steps and some of the pitfalls of using an FFT in the real world. Setup I have an ST Micro STM32F746G Discovery board. The processor is an ARM Cortex-M7 with a vector processing unit, and the ARM powers have conveniently provided an optimized DSP library as part of CMSIS . The Discovery board has a TFT LCD (480 x 272) which I will use to display the output of the FFT in graphical form. Otherwise I'm just using the microcontroller itself to sample the data and process it, not even using the external RAM available on the Discovery. Sampling Data In a n...

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...