PWM discontinuties RP2 #9349
karidavidsson
started this conversation in
General
Replies: 2 comments 1 reply
-
It's a quirk of the RP2040 that PWM duty cycle changes when you change frequency, and vice versa. You have to set both every time you change one. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@scruss If you change the frequency, the duty cycle will set internally again by the code for the freq() method to the initial state, as long as you work on a single channel. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am playing with PWM on the raspberry pico board.
When changing the PWM frequency the transition is not continuous, meaning that the duty cycle is not conserved with the new frequency.
I take care to change the frequency of both PWM channels but as seen on the image both channels get some funky intermediate duty-cycle before the final correct duty cycle which I have to set again.
The first trace changes the duty cycle from zero to 99% and the second trace should have fixed 50% duty-cycle on both frequencies.
What I would like to see is that the first trace has duty-cycle of 0 until duty-cycle of 99 is set (skip the 50% intermediary duty-cycle ). The second trace should have 50% duty-cycle the whole time and only the frequency change.
The code executes at the transition is :
Initialized by call of
setoutput( pair, 35103, 0 )
, followed by(setouput( pair, 13603, 99)
.The
pair[ 'output' ]
is the second trace (brown) andpair['led']
is the first trace (white).micropython is master as of Jul 15th 2022.
Beta Was this translation helpful? Give feedback.
All reactions