Skip to main content
JuM
Senior
August 15, 2018
Question

STM32F091 ADC DMA problem

  • August 15, 2018
  • 4 replies
  • 730 views

Problem with ADC reading at 100 kHz via DMA.

MCU runs @ 48 MHz, ADC @ 14 MHz. Configured via CubeMX.

Trying to read one ADC channel (1.5 cycles), triggered by Timer 15 (100 kHz) using HAL.

Cannot reach 100 kHz (see pictures)​. Blue are DMA interrupts (half=rising, complete=falling edge), yellow is Timer 15 interrupt (toggle).

First step with this one line Timer15 ISR:

void TIM15_IRQHandler(void) {

   HAL_GPIO_TogglePin (GPIOC, GPIO_PIN_8);

}

Rem.: 100 kHz ok.

Then add call to HAL_ADC_Start_DMA ()

void TIM15_IRQHandler(void){

   HAL_GPIO_TogglePin (GPIOC, GPIO_PIN_8);

   HAL_ADC_Start_DMA (&hadc, adc32_dma, 1);

}

Rem.: Timer frequency dropped to 56.2 kHz…

Rem.: DMA needs 4.4 µsec (incl. 1.6 µsec for DMA ISRs), not 1/2.6 µsec…

What goes wrong here?

    This topic has been closed for replies.

    4 replies

    JuM
    JuMAuthor
    Senior
    August 15, 2018

    0690X000006BtZNQA0.bmp0690X000006BtZIQA0.bmp

    JuM
    JuMAuthor
    Senior
    August 15, 2018

    0690X000006BtZIQA0.bmp

    T J
    Senior III
    August 15, 2018

    You dont want to do this:

     void TIM15_IRQHandler(void){
     
     HAL_GPIO_TogglePin (GPIOC, GPIO_PIN_8);
     
     HAL_ADC_Start_DMA (&hadc, adc32_dma, 1);
     
    }

    this is 100KHz of 5uSeconds delay you only have 10uS in 100KHz...

    I run this line Once on startup, and never again:

     MAIN:
     
     ADC_RowCounter = 0; // gather 16 rows of data
     Ave_ADC_ChannelCounter = 0;
     ADC_ChannelsCounter = ADC_ChannelCount; // 15 ADC channels
     HAL_ADC_Start_DMA(&hadc, (uint32_t *)ADC_DMABuffer, ADC_ChannelCount); 
     
    while(1){
    ...

    Tesla DeLorean
    Guru
    August 15, 2018

    >>What goes wrong here?

    Decimate the interrupt loading, buffer 10 samples via DMA

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..