cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling ADC interupt while HAL_ADC_Start_DMA using

thannara123
Senior
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
7 REPLIES 7
AScha.3
Chief III

Hi,

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

AScha3_0-1715274121705.png

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

AScha3_1-1715274229982.png

 

 

If you feel a post has answered your question, please click "Accept as Solution".
thannara123
Senior

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 ?

>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 ?

If you feel a post has answered your question, please click "Accept as Solution".
thannara123
Senior

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 .

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.

thannara123
Senior

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 ?

thannara123
Senior

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 ?