2019-02-04 07:44 AM
Hi,
I have a PWM signal input to STM32Fx MCU, I would like to count the number of pulses and trigger ADC on each rising edge of the PWM.
If I use the input as the clock source for the Timer I don't know how to generate a trigger to the ADC on each pulse without using GPIO EXTI
Please assist,
Michael
2019-02-04 08:11 AM
Find a TIM where the TIMx_CHx can trigger an ADC, and be routed the external count clock. This, or an Indirect (CH1<->CH2) input capture method should work.
2019-02-04 08:32 AM
You can have your ADC PWM pulse go directly to ADC trigger pin AND the timer if you wish to count periods. If ADC uses DMA to automatically fill a buffer, by simply checking DMA counters, you'll be able to know how many pulses and how many ADC sampled data are in the buffer.
2019-02-04 08:37 AM
Hi Clive,
Thank you for your replay.
From what I understand ADC is triggered by TIM-TRGO or TIM-CC or Ext_IT, and for counting I need to use TIM_Base with the clock being my input?
Maybe I can use TIMx-CH1 as input, than split it to TI1FP1 and TIFP2 set CC_register_1 to base mode and CC_register_2 to capture mode with period of 1?
2019-02-04 09:02 AM
Don't know what part you're using.
The input capture does CCR2 = CNT, it wouldn't really matter what CNT was doing, which presumably be a maximal setting, as you would just be using it as a trigger event. The ADC would explicitly have support for TIMx_CHx, or be mapped at the TIM to be TIMx_TRGO
The Reference Manual for the part should have a list of trigger sources.
2019-02-05 12:17 AM
I'm using STM32F051 - this is the ADC trigger
Can use TIMx_CH1 for timer clock and also for input capture?
2019-02-05 12:19 AM
Nice work-around, I'll consider it
Thanks