summaryrefslogtreecommitdiff
path: root/docs/zephyr/quickref.rst
diff options
context:
space:
mode:
authorAyush Singh <ayush@beagleboard.org>2024-10-19 13:13:39 +0530
committerDamien George <damien@micropython.org>2025-04-30 00:29:55 +1000
commitc9c39b88afe1d51b9bb4984cb19b787ac5834c52 (patch)
tree4da8cc3798696672f20949751266ad5bf6970e3c /docs/zephyr/quickref.rst
parentf4a7e713ea8b374de04c471d877e442bf6ff48e8 (diff)
docs/zephyr: Add quick reference for PWM support.
Add docs for PWM support. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
Diffstat (limited to 'docs/zephyr/quickref.rst')
-rw-r--r--docs/zephyr/quickref.rst15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/zephyr/quickref.rst b/docs/zephyr/quickref.rst
index 63d4bced0..a7ae69860 100644
--- a/docs/zephyr/quickref.rst
+++ b/docs/zephyr/quickref.rst
@@ -56,6 +56,21 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
switch = Pin(("gpioc", 6), Pin.IN) # create input pin for a switch
switch.irq(lambda t: print("SW2 changed")) # enable an interrupt when switch state is changed
+PWM
+---
+
+Use the :ref:`machine.PWM <machine.PWM>` class::
+
+ from machine import PWM
+
+ pwm = PWM(("pwm0", 0), freq=3921568, duty_ns=200, invert=True) # create pwm on PWM0
+ print(pwm) # print pwm
+
+ print(pwm.duty_ns()) # print pwm duty cycle in nanoseconds
+ pwm.duty_ns(255) # set new pwm duty cycle in nanoseconds
+
+ pwm.deinit()
+
Hardware I2C bus
----------------