Replies: 1 comment 1 reply
-
Which version of the firmware do you use on the NRF board and the Pi Pico. For the latter, it cannot be a recent one. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I had trouble with setting up PWMs.
from machine import Pin,PWM,Timer
a = PWM( Pin('LED1_GREEN', Pin.OUT) )
b = PWM( Pin('LED2_RED' , Pin.OUT) )
c = PWM( Pin('LED2_GREEN', Pin.OUT) )
d = PWM( Pin('LED2_BLUE' , Pin.OUT) )
for y in a,b,c,d:
if type(y) == PWM:
print('PWM: ',y)
result:
PWM: <PWM: Pin=12 freq=0Hz duty=0 invert=0 id=0 channel=0>
PWM: <PWM: Pin=12 freq=0Hz duty=0 invert=0 id=0 channel=0>
PWM: <PWM: Pin=12 freq=0Hz duty=0 invert=0 id=0 channel=0>
PWM: <PWM: Pin=12 freq=0Hz duty=0 invert=0 id=0 channel=0>
variant2:
a = PWM( Pin('LED1_GREEN', Pin.OUT), freq=600, duty_u16=16384 )
b = PWM( Pin('LED2_RED' , Pin.OUT), freq=500, duty_u16=8192 )
c = PWM( Pin('LED2_GREEN', Pin.OUT), freq=400, duty_u16=4096 )
d = PWM( Pin('LED2_BLUE' , Pin.OUT), freq=300, duty_u16=2048 )
for y in a,b,c,d:
if type(y) == PWM:
print('PWM: ',y)
result:
PWM: <PWM: Pin=6 freq=600Hz duty_u16=16384 invert=0 id=0 channel=0>
PWM: <PWM: Pin=8 freq=500Hz duty_u16=8192 invert=0 id=1 channel=0>
PWM: <PWM: Pin=41 freq=400Hz duty_u16=4096 invert=0 id=2 channel=0>
PWM: <PWM: Pin=12 freq=300Hz duty_u16=2048 invert=0 id=3 channel=0>
(hardware: PCA10059 with NRF52840 _mpy: 7686
uf2 version: 3.4.0; MicroPython v1.22.1 on 2024-01-05)
repl step by step:
PI-PICO W repl identical definition:
a = PWM(Pin('GP2'),Pin.OUT)
Traceback (most recent call last):
File "", line 1, in
ValueError: freq too small
(MicroPython v1.21.0, galactic_unicorn v1.21.0 on 2023-10-06; Raspberry Pi Pico W with RP2040)
First result is that it smashes up all pwms into last defined pin, pin LED2_BLUE in code.
If i declare PWMs with freq and duty all are then correctly defined including proper pins for each.
Does this behaviour count as bug in micropython implementation ?
Beta Was this translation helpful? Give feedback.
All reactions