cancel
Showing results for 
Search instead for 
Did you mean: 

How to sample at the middle of a PWM signal - STM32G071

JScho.599
Associate

This question has been asked in various forms before but I have not found an answer. I am using TIM2 to generate a center aligned PWM signal as shown in the image. I want to sample the ADC at the center of the PWM. I am using the TRGO signal of the timer to trigger the ADC. However, it seems that regardless of how I configure the TRGO, there are always two events triggered per PWM period instead of one. Is it possible somehow just to create one trigger event or do I need to chain another timer or switch to a more capable timer, e.g. TIM1?

2 REPLIES 2

Try TIMx_CR1.CMS=0b01 or 0b10 and TRGO selected as 0b011: Compare Pulse from CC1.

JW

S.Ma
Principal

For debug purpose, use another channel to generate the trigger signal and feed it to the ADC trigger input pin. Confirm the basic first, then try to use internal signaling.