-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
It appears that as long as you don't change the value of freq, it continues to work. But 'sometimes' a change in frequency will fail. This is most likely because the underlying MicroPython library is doing some kind of magic to check for valid values.
Here is an example:
mosfet_pwm = PWM(Pin(4), freq=15000) # 15kHz
mosfet_pwm = PWM(Pin(4), freq=15000) # 15kHz
mosfet_pwm = PWM(Pin(4), freq=30000) # 30kHz
Traceback (most recent call last):
File "", line 1, in
ValueError: unreachable frequency 30000
mosfet_pwm = PWM(Pin(4), freq=30000) # 30kHz
If you run the function again, it appears to work correctly. Might need to be wrapped in a small loop or try catch.
Metadata
Metadata
Assignees
Labels
No labels