Skip to content

PWMOut can fail to act on changes to duty_cycle on nRF52840 board #3387

@kevinjwalters

Description

@kevinjwalters

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions