diff options
author | robert-hh <robert@hammelrath.com> | 2023-02-25 10:51:56 +0100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-05-04 13:15:55 +1000 |
commit | dc8f9d22ca2ec9328b519e79013c97bbbe18b6c6 (patch) | |
tree | d4f5ce3e6f205e5b1c3dd541142395f3d60b0d1a /docs/samd | |
parent | 84302b2854334371217015a5924978c009a94d30 (diff) | |
download | micropython-dc8f9d22ca2ec9328b519e79013c97bbbe18b6c6.tar.gz micropython-dc8f9d22ca2ec9328b519e79013c97bbbe18b6c6.zip |
docs: Update the PWM examples based on recent API improvements.
This adds the freq and duty_u16 keyword settings to the constructor, and
sometimes other details in the PWM section.
For mimxrt a clarification regarding the PWM invert argument was added, and
for rp2 a few words were spent on PWM output pairs of a channel/slice.
Diffstat (limited to 'docs/samd')
-rw-r--r-- | docs/samd/quickref.rst | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/docs/samd/quickref.rst b/docs/samd/quickref.rst index 7a0786d4ca..7da855cb37 100644 --- a/docs/samd/quickref.rst +++ b/docs/samd/quickref.rst @@ -178,11 +178,12 @@ It supports all basic methods listed for that class. :: from machine import Pin, PWM - pwm = PWM(Pin(7)) # create PWM object from a pin - pwm.freq() # get current frequency - pwm.freq(1000) # set frequency - pwm.duty_u16() # get current duty cycle, range 0-65535 - pwm.duty_u16(200) # set duty cycle, range 0-65535 + # create PWM object from a pin and set the frequency and duty cycle + pwm = PWM(Pin('D7'), freq=2000, duty_u16=32768) + pwm.freq() # get the current frequency + pwm.freq(1000) # set/change the frequency + pwm.duty_u16() # get the current duty cycle, range 0-65535 + pwm.duty_u16(200) # set the duty cycle, range 0-65535 pwm.deinit() # turn off PWM on the pin pwm # show the PWM objects properties @@ -213,9 +214,6 @@ PWM Constructor - *freq* should be an integer which sets the frequency in Hz for the PWM cycle. The valid frequency range is 1 Hz to 24 MHz. - *duty_u16* sets the duty cycle as a ratio ``duty_u16 / 65536``. - The duty cycle of a X channel can only be changed, if the A and B channel - of the respective submodule is not used. Otherwise the duty_16 value of the - X channel is 32768 (50%). - *duty_ns* sets the pulse width in nanoseconds. The limitation for X channels apply as well. - *invert*\=True|False. Setting a bit inverts the respective output. |