cancel
Showing results for 
Search instead for 
Did you mean: 

How to setup a multi channel ADC + DMA by the use of the LL lib for the STM32F4?

Stef1
Associate

Hey,

I like to build a STM32F4 ADC DMA demo for the ZephyrOS project. The goal of the demo is to write a simple ADC driver, that inits its self and the ADC & DMA. Additional a thread triggers every 10sec a conversation.

Currently I am struggling to setup the ADC and maybe DMA in the right way. Any idea is appreciated.

My demo setup :

Idea setup uint16[3] vector that received the result of the conversation. Start conversation and wait for interrupt(ISR handler). the DMA runs in a circular mode, so we do not need to reset the DMA memory pointer before every conversation. At the end of the conversation we are getting the DMA TC interrupt. Inside of the ISR handler a semaphore is set that.

MCU: stm32f412

ADC1:

  • 12Byte, right aligned
  • PCLK /8
  • scan mode: on
  • continuous mode: off
  • discontinuous mode: off
  • regular mode:
    • number of conversations: 3
    • ranks:
      • rank 1: PC1 (channel 11)
      • rank 2: PC3 (channel 13)
      • rank 3: VRefInt (channel VRef)

DMA2:

  • stream 0
  • circular
  • increment addr peripheral: off
  • increment addr memory: on
  • enable transfer complete interrupt (TC)

I setup this setup at cubeMX and let it generate the code for me. I attached the file.

When running my code. I am calling the function in that order:

  1. adc_dma_stm32_initilize
  2. adc_dma_stm32_init
  3. adc_dma_stm32_doConv

The DMA or ADC iSR is never called. Think I have some error at my setup.

1 REPLY 1
Stef1
Associate

the LL_DMA_EnableStream function must be called to enable the DMA streaming. That solves that problem