docs/zephyr: Add quick reference for PWM support.
Add docs for PWM support. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
This commit is contained in:
parent
f4a7e713ea
commit
c9c39b88af
1 changed files with 15 additions and 0 deletions
|
|
@ -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
|
||||
----------------
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue