Replies: 3 comments
-
You might have better luck at the Raspberry Pi forums since this is a low-level HW question. |
Beta Was this translation helpful? Give feedback.
-
Yep, that's where I started (and other forums), since PWM phase shift is not often discussed I figured I'd post here where the cool kids hang out lol.
|
Beta Was this translation helpful? Give feedback.
-
Hello,
I am looking to advance/retard a PWM signal on a given pin by using the
pwm_set_counter(...)
relative to a steady signal on another pin. These two pins are not on the same "slice" so independent setup and control should be possible.My basic challenge is to map a given delay/advance time T to the correct values to send via the
pwm_set_counter
.As the RP2040 uses an 8.4 fractional counter...and so forth, i hoped to be able to do this without being concerned about the PWM frequency just by factoring in the divisor for the slice which I can get from
pwm_hw->slice[slice_num].div
. I can advance/delay the PWM signal, but my math for determining the correct 'counter' value for a given T is embarrassingly wrong. The basic algo is here...I am trying to pivot around the system clock and factor in the divisor... I get
200
for the whole portion of the fractional divisor and128
for the fraction part, they appear to be legit values... So the missing math is where it's at... I am suspecting now that this can't be done without considering the PWM signal frequency and possibly the duty cycle as well as the meaning of the divisor to the counter does not appear to be constant. Getting this working in phase corrected mode would be ideal.Any suggestions would be appreciated
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions