Skip to content

Commit c9c39b8

Browse files
Ayush1325dpgeorge
authored andcommitted
docs/zephyr: Add quick reference for PWM support.
Add docs for PWM support. Signed-off-by: Ayush Singh <[email protected]>
1 parent f4a7e71 commit c9c39b8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/zephyr/quickref.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
5656
switch = Pin(("gpioc", 6), Pin.IN) # create input pin for a switch
5757
switch.irq(lambda t: print("SW2 changed")) # enable an interrupt when switch state is changed
5858

59+
PWM
60+
---
61+
62+
Use the :ref:`machine.PWM <machine.PWM>` class::
63+
64+
from machine import PWM
65+
66+
pwm = PWM(("pwm0", 0), freq=3921568, duty_ns=200, invert=True) # create pwm on PWM0
67+
print(pwm) # print pwm
68+
69+
print(pwm.duty_ns()) # print pwm duty cycle in nanoseconds
70+
pwm.duty_ns(255) # set new pwm duty cycle in nanoseconds
71+
72+
pwm.deinit()
73+
5974
Hardware I2C bus
6075
----------------
6176

0 commit comments

Comments
 (0)