diff options
| author | IhorNehrutsa <Ihor.Nehrutsa@gmail.com> | 2024-12-16 14:44:37 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2025-05-16 12:34:32 +1000 |
| commit | c310301f27e351e0dc9f966556cab512b3c82615 (patch) | |
| tree | 79dff427df44b2556f5ba2a4fa510b22a1f24453 /docs/library | |
| parent | 6d74b4e3c15d0b677247ce02c459095d3cf03fc5 (diff) | |
docs/esp32: Improve PWM documentation and examples.
This reduces inconsitencies between esp32 and other ports.
According to the discussion in #10817.
Signed-off-by: Ihor Nehrutsa <Ihor.Nehrutsa@gmail.com>
Diffstat (limited to 'docs/library')
| -rw-r--r-- | docs/library/machine.PWM.rst | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/docs/library/machine.PWM.rst b/docs/library/machine.PWM.rst index 5f592b8df..c2b606aff 100644 --- a/docs/library/machine.PWM.rst +++ b/docs/library/machine.PWM.rst @@ -11,20 +11,20 @@ Example usage:: from machine import PWM pwm = PWM(pin, freq=50, duty_u16=8192) # create a PWM object on a pin - # and set freq and duty - pwm.duty_u16(32768) # set duty to 50% + # and set freq 50 Hz and duty 12.5% + pwm.duty_u16(32768) # set duty to 50% # reinitialise with a period of 200us, duty of 5us pwm.init(freq=5000, duty_ns=5000) - pwm.duty_ns(3000) # set pulse width to 3us + pwm.duty_ns(3000) # set pulse width to 3us pwm.deinit() Constructors ------------ -.. class:: PWM(dest, *, freq, duty_u16, duty_ns, invert) +.. class:: PWM(dest, *, freq, duty_u16, duty_ns, invert=False) Construct and return a new PWM object using the following parameters: @@ -40,7 +40,7 @@ Constructors Setting *freq* may affect other PWM objects if the objects share the same underlying PWM generator (this is hardware specific). Only one of *duty_u16* and *duty_ns* should be specified at a time. - *invert* is not available at all ports. + *invert* is available only on the esp32, mimxrt, nrf, rp2, samd and zephyr ports. Methods ------- @@ -116,10 +116,10 @@ Limitations of PWM resolution of 8 bit, not 16-bit as may be expected. In this case, the lowest 8 bits of *duty_u16* are insignificant. So:: - pwm=PWM(Pin(13), freq=300_000, duty_u16=2**16//2) + pwm=PWM(Pin(13), freq=300_000, duty_u16=65536//2) and:: - pwm=PWM(Pin(13), freq=300_000, duty_u16=2**16//2 + 255) + pwm=PWM(Pin(13), freq=300_000, duty_u16=65536//2 + 255) will generate PWM with the same 50% duty cycle. |
