2025-03-02 8:34 AM
I'm using NucleoG071RB for this experiment. I have an (periodic) external signal that should reset the Timer counter to zero, so that the PWM is synchronized to the external signal. I used the external signal to generate an interrupt (EXTI), and reset the counter in software (TIM1->CNT = 0). There is latency detected when the signals are measured with an oscilloscope. I tried to use Timer Input Capture as an alternative but to no avail. Is there any other alternative to approach this? Thank you in advance.
2025-03-02 11:18 AM - edited 2025-03-02 11:18 AM
This is what the Slave-mode controller in the Timers is for. Read description of the TIMx_SMCR register in Timer chapter in RM.
Set up one of TIMx_CH1 or TIMx_CH2 pins for AF in GPIOx_MODER and set the proper AF number in GPIOx_AFR[]. In timer, set respective TIMx_CCMR1.CCxS to 0b01 so set given pin as input (up to this point the setup is similar to as if you'd want to use Input Capture for given pin). Set TIMx_SMCR.TS to 0b101 or 0b110 for TIxFPx, i.e. output of TIMx_CHx digital input filter. Finally, set TIMx_SMCR.SMS to 0b100 for Reset mode.
Maybe this can be somehow clicked in CubeMX, I don't know, I don't use it.
JW