forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
On a CLUE running 5.3.1 there appears to be some timing issue where if the frequency is changed and then the duty_cycle immediately afterwards the latter does not take effect.
Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit CLUE nRF52840 Express with nRF52840
>>> import board
>>> import pulseio
>>> import time
>>> board.DISPLAY.auto_refresh = False
>>> pwm_p0 = pulseio.PWMOut(board.P0, frequency=50, duty_cycle=0, variable_frequency=True)
>>> pwm_p0.frequency = 440 ; pwm_p0.duty_cycle = 9000 # No output
>>> print(pwm_p0.frequency, pwm_p0.duty_cycle)
440 9000
>>> pwm_p0.frequency = 440 ; pwm_p0.duty_cycle = 9000 # PWM output visible on 'scope
If I stick a 10ms pause in there everthing is fine:
Adafruit CircuitPython 5.3.1 on 2020-07-13; Adafruit CLUE nRF52840 Express with nRF52840
>>> import board
>>> import pulseio
>>> import time
>>> board.DISPLAY.auto_refresh = False
>>> pwm_p0 = pulseio.PWMOut(board.P0, frequency=50, duty_cycle=0, variable_frequency=True)
>>> pwm_p0.frequency = 440 ; time.sleep(0.010) ; pwm_p0.duty_cycle = 9000 # this works as expected