Hello, I study the stm32 TSP recently. I find that the demo advanced_pwm_configuration about the stm32G431 PWM Capture has some problem. The value of PWM Capture is incorrect when the given frequency is below 3kHz. Why does this situation occur? I know that the G431 is not contain HRTIM, So If I want to recognize the frequency from 1 Hz to 10kHz, what should I do?
Hi xuli,
It is difficult to diagnose the issue without a model.
Most likely, the issue is related to the combination of the peripheral clock frequency and the maximum counter range available in the hardware. The frequency range you are trying to achieve may simply fall outside the achievable range for the selected configuration.
hello, Munadir_Ahmed,
I use the demo which is “Advanced PWM Configuratin”. Please refer to the attached file.
advanced_pwm_configuration.plecs (273.2 KB)
Hello,
Thank you for attaching the model!
The reason for this is that the PWM period exceeds the maximum period that can be measured using the TIM peripheral used by the Capture block for a given system clock frequency when it drops below approximately 25 % of the initial PWM frequency. To extend the range, you could switch to the individual channel mode and increase the clock prescaling.
PWM_Capture.plecs (35.7 KB)
Hello,when I swtich the model to the individual channel mode, and I set the prescal to 170-1. then I modify the value of frequency, the value of PWM Capture has not changed. Could you give me some advice or a demo?
Hello Xuli,
My previous response was unhelpful! It seems that the individual channel mode for the STM32 TSP is not as mature as for the TI C2000 and XMC TSPs and it would be difficult to use it to capture the PWM period and duty cycle.
Instead of using a clock prescaler, you could also change from a 16-bit timer to a 32-bit timer. I modified your model accordingly:
PWM_Capture_32_bit_TIM.plecs (36.8 KB)
It is useful
, thank you very much. The demo “Advanced PWM Configuratin” may need to updated in latest version. ![]()