-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PWM silently fails when changing output frequency on stm32 #28278
Comments
I can now confirm the behavior is identical on stm32f411e_disco. The behavior is correct on nrf52840 (however I discovered a different issue on there that causes a device hang after a long time) |
^^@gmarull |
I am not sure if this is related, but I am also noticing that the frequency resolution is really low. Trying to change between 2400 and 2800 for instance doesn't actually change the output. I was hoping to achieve 10Hz resolution on the PWM output. I notice that the result of Edit: I realize the prescaler is set in the device tree, and was indeed set to 10000. Changing this to 100 appears to give the frequency resolution I was hoping for. Surprisingly, the dropouts are significantly reduced with this change as well. It fails at < ~700Hz, but otherwise appears to work normally. So perhaps it is related in some way? |
After some quick tests I think that the problem you are observing is related to the pre-scaler value you're using (default to 10000 unless you change it on DT). Using default prescaler I see that pulse_cycles end up reaching 0 on your sample, for which timer output is disabled (as documented by the API). You will need to adjust timer pre-scaler to meet your requirements. |
Gotcha. I noticed I was still getting occasional dropouts when I lowered the prescaler to 100, but I will need to narrow down those instances specifically and make sure that is all that is happening. |
Lowering bug priority. |
Describe the bug
When trying to change the pwm frequency with
pwm_pin_set_usec
, the output will regularly dropout. The behavior is reproduced more quickly by changing the frequency more often. If I change it at about a 1 second interval, it fails about 10% of the time, and if I change it at 100ms, it fails most of the time.To Reproduce
Here is a basic example which reproduces the behavior
Expected behavior
I expect this to perform a sweep through frequencies from 100Hz to 5Khz in 100Hz steps, changing frequencies by 100Hz every 100ms. I would also expect that I could do this at a much higher rate than this.
Impact
Major impact for my use case, as this project requires a frequency sweep on a piezo to be performed, and dropouts aren't acceptable.
Environment (please complete the following information):
Additional context
I am specificially using the blackpill_f411ce board for these tests, but have disco and nucleo boards available to test if required.
The text was updated successfully, but these errors were encountered: