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

General • Re: Understand better PWM and channels (long)

$
0
0
I have understood the Pico W has 8 independent PWM generators called slices (from PWM0 to PWM7), and each slice has two channels (A and B), which makes a total of 16 PWM output (or input/output using the C/C++ SDK).

1) Looks like the output of these slices/channels (https://mischianti.org/wp-content/uploa ... hianti.png) are linked to the GPIO from 0 to 15 (from PWM0A to PWM7B), but what about the pin from GPIO16 to GPIO28 (except GPIO23, 24, 25, 29 because used internally)? Are they a simple duplication or do they change something to the signal?
Simple duplication/alternate pins
2) The C/C++ SDK API documentation (https://www.raspberrypi.com/documentati ... 222465dcff) said "...All 30 GPIOs can be driven by the PWM block...". What are these 30 GPIO? I count only 26 pin available. Do you have an alternative picture?
Other GPIOs are used internally for things like the on board LED (Pico), Wifi/bluetooth (Pico W), and power monitoring (both). See page 7 of the Pico datasheet and page 8 of the Pico W datasheet
3) What's the meaning to have two channels for every slice? I know a PWM signal is defined by the frequency and the duty cycle, and when a frequency is set for a generator (i.e. PWM0) every channel linked to it (PWM0A and PWM0B) use the same frequency, but what the duty cycle? Can I set it independently for each channel or at the end the two outputs are exactly the same signal?
The duty cycle is independent for each PWM channel. A and B must have the same frequency, but can have different duty cycles.
4) For the "duplicated" output (i.e. the GPIO0 and GPIO16 are linked at the same PWM0A), can I used them at the same time?
I believe so.
5) When I activate a PWM (i.e. GPIO0 with PWM0A) the twin pin (GPIO1 with PWM0B) is still usable for different use (i.e as an input pin) or it become unavailable?
The other pin can be set to any function you want.
6) On Micropython (but not on the C/C++ SDK) the PWM class constructor (https://docs.micropython.org/en/latest/ ... e.PWM.html) has a parameter called "invert" to invert the output (I suppose the duty cycle) but it states is not available at all ports. Do you know on what ports are not available?
I don't know on which other ports of MicroPython the invert isn't supported, but it is fully supported on all GPIO pins in the RP2040 one.
7) Always on Micropython, the function deinit() disables the PWM output (but it doesn't accept any parameters, for example which pin). What does mean? Does it disable all generators on the board?
I don't know the answer to this one.

Statistics: Posted by rpdom — Thu May 02, 2024 8:11 am



Viewing all articles
Browse latest Browse all 8082

Trending Articles