cancel
Showing results for 
Search instead for 
Did you mean: 

Is A/D conversion possible during the timer interrupt routine?

Yyosh.1
Associate

Hello.

I have a question about the STM32G473 ADC.

I want to perform A/D conversion at the TIM6 event, but the DMA transfer is performed only once at the beginning, and the transferred data becomes 0 after that.

The ADC is set to dual regular simultaneous mode only.

There is no problem if A/D conversion is performed in the main routine.

The interrupt priority is as follows.

・TIM6 level 3

・DMA level 0

Is it not possible to perform A/D conversion () within the timer interrupt?

/* code​ in TIM6 event*/

dma_comp_flag = False;

HAL_ADC_Start( hadc2);

HAL_ADCEx_MultiModeStart_DMA(hadc1, (uint32_t*)rawData, 1);

while(dma_comp_flag == False)

{

;

}

​/* end */

3 REPLIES 3
nico 2010
Associate II

Can you put the code here?

I guess that you have to trigger ADC using TIM event (TIM_TRGO_UPDATE is usual used),

Something like this:

In my case I use sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC1;

	HAL_TIM_OC_Start(&htim1, TIM_CHANNEL_1);
	HAL_ADC_Start_DMA(&hadc1, (uint32_t*) adc1_dma_buff, ADC_DMA_BUFFSIZE);

Yyosh.1
Associate

nico 2010-san

Thank you for your reply.

I will try the method of triggering the ADC using TIM.

I'm new to ST-MCU, so I don't fully understand how to use the HAL API. Especially when using the ADC in dual mode, the API function to use is unclear.

Is there any sample code or documentation for HALAPI?

I can only find simple documentation. (Attachment document :UM2570 Description of STM32G4 HAL and low-layer drivers)

0693W000003REf4QAG.png

Thanks in advance.

nico 2010
Associate II

Hi,

Did you search and doownload stm32cube_fw_g4_v120 on ST site resources?

There you will find examples of ADC conversion triggered by Timer