cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger ADC from TIM1 internally?

JSmit.11
Associate II

Hi All,

I am using STM32F410RB chip.

I want to make launch adc from timer periodically.

From reference manual (RM0401) ADC can be triggered from TIM1_CH1 event.

On figure 49 the only connection from TIM1 to ADC is TRGO.

And from the same figure this TRGO can be triggered by ITR0-ITR3 or by TIF_ED.

How this can be related to TIM1_CH1 event.

From TIM1 description TIM1_CH1 event can be triggered when input compare or output 

compare events are triggered. But I don't need external pint TIM1_CH1.

If we don't use external pin how to setup TIM1_CH1 event when CNT overwlows?

I have configured TIM1 without any output pins.

I see that the CNT counter is updating but ADC is not working.

Is it possible to trigger ADC from TIM1 without configuring external poins.

How to trigger TIM1_CH1 event?

Thanks,

4 REPLIES 4
Mohamed Aymen HZAMI
ST Employee

Hello @Community member​ and welcome to the community,

You can refer to the attached example that I generated using STM32CubeMx

in the ADC Configuration I only set the external Trigger to Timer 1 Capture Compare 1 event


_legacyfs_online_stmicro_images_0693W00000dDPjXQAW.pngThe Timer configuration is as in the screen below:


_legacyfs_online_stmicro_images_0693W00000dDPpGQAW.pngYou need to set the output compare No Output Channel 1 mode to Toggle on match

ps: I attached the project with the .ioc file

Mohamed Aymen

JSmit.11
Associate II

Hello,

Thanks for reply.

I am using STM32f410RBT6 chip not bga.

I have checked my settings. They are the same as you provided.

But ADC still not working.

Maybe I am launching ADC wrong?

I enable ADC interrupt and call two functions.

HAL_TIM_Base_Start_IT(&htim1);

HAL_ADC_Start_IT(&hadc1);

I see that ADC interrupt is not triggered. Although TIMI1 is counting.

I see it in peripherals view on the Keil.

But no iterrupts of ADC are trigered.

You actually need to enable TIM1_CH1 output (you don't need to assign a pin in GPIO, but I don't know how does this work in CubeMX - if you assign a pin, you at least can check that the triggering signal works). This means that you can't use the "No output" selection and in TIM1 you have to enable also TIM1_BDTR.MOE.

JW

JSmit.11
Associate II

Thanks to all for help.

My error was that i was using Srart_timebase function instead of HAL_TIM_OC_Start.

now it works fine