Skip to main content
VK.3
Associate II
August 29, 2023
Question

STM32F103 external Timer trigger for ADC

  • August 29, 2023
  • 2 replies
  • 1472 views

Hi all.

I'm using STM32F103C and want the Timer1 Capture/Compare event to trigger ADC conversion. Two ADCs operate in dual regular simultaneous mode.

At the moment, I have a working Timer1 with CC1 and CC2 interrupts and two ADCs that operate in dual regular simultaneous mode (software trigger). This configuration works well.

I'm trying to modify the code to trigger ADC conversion with the CC2 event but to no avail.

The code modifications I have tried are

 

// ADC1 config
// ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC2;
ADC_ExternalTrigConvCmd(ADC1, ENABLE);	// added
...
// ADC2 config
// ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC2;
ADC_ExternalTrigConvCmd(ADC2, ENABLE); // added

 

Question: are there any other suggestions that I can try? Am I missing something in the configuration?

This topic has been closed for replies.

2 replies

ST Employee
August 31, 2023

Hello @VK.3, 

Make sure TIM1's MOE in TIM1_BDTR is set.

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
VK.3
VK.3Author
Associate II
September 1, 2023

Hi @Sarra.S .

Thanks for your reply.

The MOE bit was 0. I set it to 1. But the result is the same. The timer doesn't trigger ADC conversion.