@@ -40,13 +40,13 @@ class Timer -- control internal timers
4040 Further examples::
4141
4242 from machine import Timer
43- tim1 = Timer(2 , mode=Timer.ONE_SHOT) # initialize it in one shot mode
44- tim2 = Timer(1 , mode=Timer.PWM) # initialize it in PWM mode
43+ tim1 = Timer(1 , mode=Timer.ONE_SHOT) # initialize it in one shot mode
44+ tim2 = Timer(2 , mode=Timer.PWM) # initialize it in PWM mode
4545 tim1_ch = tim1.channel(Timer.A, freq=10, polarity=Timer.POSITIVE) # start the event counter with a frequency of 10Hz and triggered by positive edges
46- tim2_ch = tim2.channel(Timer.B, freq=10000, duty_cycle=50) # start the PWM on channel B with a 50% duty cycle
46+ tim2_ch = tim2.channel(Timer.B, freq=10000, duty_cycle=5000) # start the PWM on channel B with a 50% duty cycle
4747 tim2_ch.freq(20) # set the frequency (can also get)
48- tim2_ch.duty_cycle(30 ) # set the duty cycle to 30% (can also get)
49- tim2_ch.duty_cycle(30 , Timer.NEGATIVE) # set the duty cycle to 30% and change the polarity to negative
48+ tim2_ch.duty_cycle(3010 ) # set the duty cycle to 30.1 % (can also get)
49+ tim2_ch.duty_cycle(3020 , Timer.NEGATIVE) # set the duty cycle to 30.2 % and change the polarity to negative
5050 tim2_ch.period(2000000) # change the period to 2 seconds
5151
5252.. note ::
@@ -185,7 +185,9 @@ Methods
185185
186186 .. method :: timerchannel.duty_cycle([value])
187187
188- Get or set the duty cycle of the PWM signal (in the range of 0-100).
188+ Get or set the duty cycle of the PWM signal. It's a percentage (0.00-100.00). Since the WiPy
189+ doesn't support floating point numbers the duty cycle must be specified in the range 0-10000,
190+ where 10000 would represent 100.00, 5050 represents 50.50, and so on.
189191
190192Constants
191193---------
0 commit comments