Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8015

General • Accessing the phase-correct PWM up/down bit

$
0
0
Is there any (possibly undocumented) way to access the up/down bit that indicates the current direction of counting of PWM in phase-correct mode? All I've found so far is that the bit is always cleared to "up" direction when loading the counter value (best done while stopped), but is there any way to read it (other than repeated reads to see how the counter value changes) or set it to "down" direction?

To generate multi-phase interleaved PWM, some of the phases need over 180 degrees of offset. Haven't played with the RP2350 yet, but on RP2040 I've found a workaround where the initial counter value is negative. So for 3 phases the initial counter values are set to -period/3, 0, period/3 where period=(TOP+1)*2 in phase correct mode, then all counters are started and increment until TOP (if initially negative, will cross zero and still increment until TOP, then decrement as normal). Though it's not well documented, will it work that way in newer chips too? If this is something that can be guaranteed to work, might be a good idea to mention this in the datasheet.

Statistics: Posted by marekm72 — Sun Dec 28, 2025 5:06 pm



Viewing all articles
Browse latest Browse all 8015

Trending Articles