cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L0 + ADC + DMA

Muscle Man
Associate III
Posted on May 18, 2018 at 16:55

Hi to all,

I want to write some code (using HAL) to make ADC conversions of multiple channels using DMA on a STM32L073 MCU; Here some settings that the MCU will have:

  • every group conversion is triggered by a TRGO event coming from TIM6 (programmed to generate a 1 KHz clock);
  • I don't want use ADC continuous mode, so no DMA circular mode will be used;
  • the MCU's system clock, the APBCLK1 and APBCLK2 domain clocks are both set to 32 MHz;
  • the ADC peripheral is programmed to have a 8 MHz clock (synchronous to APBCLK2 domain);
  • the SYSTICK exception has the highest NVIC priority (0).

Here some questions that I want to pose:

  1. Is it OK to give to the DMA channel 0 (the one that will serve the ADC requests) the NVIC priority equal to 1, i.e a little bit lower than the SYSTICK?
  2. When DMA is used to manage the ADC conversion, is the only possible value to be assigned to 

    EOCSelection 

    of 

    ADC_InitTypeDef

    structure equal to 

    ADC_EOC_SEQ_CONV

    ?
  3. Normally I will put 

    DiscontinuousConvMode

    of 

    ADC_InitTypeDef

     structure to

    DISABLE

    .

    In

    this way, when the  

    HAL_ADC_ConvCpltCallback()

    will be invoked by DMA IRQ Handler, will the EOS flag the only one set?

    I.e, will HAL_ADC_ConvCpltCallback()

    be called only when all the ADC conversions will be made? Or will it called at the end of every ADC channel conversion?
  4. Only one sampling time will be common to all the ADC channel?

  5. When the 

    HAL_ADC_ConvCpltCallback()

    will be invoked

     with EOS flag set, I have to stop the DMA (via a call to

    HAL_ADC_Stop_DMA()

    and then to restart it again (by means of a call to HAL_ADC_Start_DMA()) to ensure a DMA proper operation?

Thanks in advance to everyone who will give some answers.

Scrat75.

0 REPLIES 0