Skip to main content
Graduate II
May 9, 2024
Question

Enabling ADC interupt while HAL_ADC_Start_DMA using

  • May 9, 2024
  • 5 replies
  • 1685 views
Hai all
When I use HAL_ADC_Start_DMA(&hadc, ADC_RES, 160); this function .How to enable ADC interupt bit .
I want to Trigger void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{ HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_6);}
this funtion How to enable it while using DMA
    This topic has been closed for replies.

    5 replies

    Super User
    May 9, 2024

    Hi,

    what interrupts are : enable+priority , set in nvic ->

    AScha3_0-1715274121705.png

    + callbacks : enable , set in advanced -> right side...

    AScha3_1-1715274229982.png

     

     

    Graduate II
    May 10, 2024

    Thanks to know that way . But  i didnt get well 

    I need as follows 

    Am generating PWM using Via DMA array (TIM1 + update Event )

    am aslo trigger an ADC via the same TIM1 update event and saving to DMA array by using the following function 

     HAL_ADC_Start_DMA(&hadc, ADC_RES, 160);

    But when using this funtion athe ADC is not generate the interrupt  ie  ,the void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

    when i use HAL_ADC_START_IT it will generate ADC interrupt 

    But not HAL_ADC_Start_DMA().

     

    I want ADC interrupt trigger  with each sample of adc HAL_ADC_Start_DMA().

    How to achive it ?

    Super User
    May 10, 2024

    >I want ADC interrupt trigger  with each sample of adc HAL_ADC_Start_DMA().

    Why then use DMA ?

    And what you wanna do in the int then ?

    Graduate II
    May 10, 2024

    ADC data should save to array by using DMA  HAL_ADC_Start_DMA().

    and it is working am able to  see the data saved in array .

    But I need funtion to do whenever each adc samapled . 

    so I required ADC interrupt .

    Graduate II
    May 10, 2024

    This isnt by design. When you trig ADC by timer use timer int for this . But normal way is ADC DMA half and full int and function do over half buffer stored.

    Graduate II
    May 10, 2024

    Hi Ok

    Can i update the ADC interuupt bit likewise as follows 

    ADC1->CR |= ADC_CR_ADIE;

    or like low level access the concerned bit 

    i am not good programmer sorry for the silly question ?

    Graduate II
    May 10, 2024

    HAL_ADC_Start_IT(&hadc);

     

    HAL_ADC_Start_DMA(&hadc, ADC_RES, 160);

     

    Called HAL_ADC_Start_IT(&hadc);function firstly only for enable the interrupt

    HAL_ADC_Start_DMA(&hadc, ADC_RES, 160); and called it

     

    And worked as expected is there any problamatic situation

    I called HAL_ADC_Start_IT(&hadc); just for tregger the adc after conversion

    is it a correct way ?