STM32F4 Floating Point FIR C Project with ADC, DAC, DMA, and FPU

Make it to the Right and Larger Audience

Download/IP

STM32F4 Floating Point FIR C Project with ADC, DAC, DMA, and FPU

This is a C based project implementing FIR filtering on ST STM32F4 microcontroller. STM32F4 is based on ARM’s popular low power Cortex-M4 core. The following is block diagram of this FIR project.

fir_blockd

 

The main functionality is to get ADC samples, low pass filtering it with FIR, sends filtered data out through DAC. As can be seen, DMA is heavily used in this project. DMA2 is used to interface to ADC and DMA1 is used to interface to DAC. For ADC we use channel 6 and for DAC we use channel 1. FIR filtering is done using CM4 floating point FPU unit. We first do integer to float conversion, call FPU for FIR filtering, then convert floating point result back to Q15 integer.

 

The following is STM32F4 AHB bus matrix diagram. DMA1 and DMA2 are two of the bus maters.

32f4_bus

DMA1 controller configuration. We use stream5 channel7 for DAC.

32f4_dma1

 

DMA2 controller configuration. We use stream0 channel0 for ADC.

32f4_dma2

 

We use DMA double buffer mode.

32f4_dma_dblbuf

 

As mentioned, FIR is done in floating point using CM4 FPU unit.

32f4_fpu1

 

 

 

 

32f4_fpu2

 

Here is the DMA2 configuration code for ADC part:

 

Here is DMA1 configuration for DAC:

 

Here is DMA2 interrupt source routine which handles FPU FIR filtering:

 

The full STM32F4 Technical tutoring slides and full FIR project code are on the 2nd page.

 
Profile Photo
Consultant at Independent
Independent consultant. 10 year experience in firmware design, from driver, RTOS to full-blown firmware package.
Tags:

4 Comments
  1. josan 7 months ago
    0
    -0

    In order to use DAC in STM32L4 I have some problems to obtain a good converted signal with ramps between output samples which produce dirty output when amplified by any audio amplifier.
    Any suggestion about correct configuration?
    I have seen in your code a triangle amplitude of 2047 and enabled output buffer, I dont understand becouse a triangle parameter?
    Thanks in advance.

    0
  2. haohht 8 months ago
    0
    -0

    Good code and reference. Get me started with STM32 firmware.
    Curious. Why mem to mem is not supported by DMA circular and double buffer modes? Under what condition to use circular and double buffer modes?

    0
  3. IanH 2 years ago
    0
    -0

    Good code and reference. Get me started with STM32 firmware.
    Curious. Why mem to mem is not supported by DMA circular and double buffer modes? Under what condition to use circular and double buffer modes?

    5

Contact Us

Thanks for helping us better serve the community. You can make a suggestion, report a bug, a misconduct, or any other issue. We'll get back to you using your private message ASAP.

Sending

©2017  ValPont.com

Forgot your details?