Description
When using the following code, I am getting the error that all the timers are used for pinblue(GP19)
import pwmio
import board
pinred = pwmio.PWMOut(board.GP17, frequency=5000, duty_cycle=0)
pingreen = pwmio.PWMOut(board.GP18, frequency=5000, duty_cycle=0)
pinblue = pwmio.PWMOut(board.GP19, frequency=5000, duty_cycle=0)
code.py output:
Traceback (most recent call last):
File "code.py", line 7, in
ValueError: All timers for this pin are in use
On the REPL this was reproduced
Adafruit CircuitPython 6.2.0-beta.1 on 2021-01-27; Raspberry Pi Pico with rp2040
import pwmio
import board
pinred = pwmio.PWMOut(board.GP17, frequency=5000, duty_cycle=0)
pingreen = pwmio.PWMOut(board.GP18, frequency=5000, duty_cycle=0)
pinblue = pwmio.PWMOut(board.GP19, frequency=5000, duty_cycle=0)
Traceback (most recent call last):
File "", line 1, in
ValueError: All timers for this pin are in use
Inversing the order of the pin definition will throw the same error, so I am assuming this is related with the pwmio definitions
Adafruit CircuitPython 6.2.0-beta.1 on 2021-01-27; Raspberry Pi Pico with rp2040
import pwmio
import board
pinred = pwmio.PWMOut(board.GP17, frequency=5000, duty_cycle=0)
pinblue = pwmio.PWMOut(board.GP19, frequency=5000, duty_cycle=0)
pingreen = pwmio.PWMOut(board.GP18, frequency=5000, duty_cycle=0)
Traceback (most recent call last):
File "", line 1, in
ValueError: All timers for this pin are in use
This code will pass
import pwmio
import board
ping1 = pwmio.PWMOut(board.GP21, frequency=700)
ping2 = pwmio.PWMOut(board.GP22, frequency=5000)
ping4 = pwmio.PWMOut(board.GP11, frequency=400)
ping5 = pwmio.PWMOut(board.GP16, frequency=400)
this will fail
import pwmio
import board
ping1 = pwmio.PWMOut(board.GP21, frequency=700)
ping2 = pwmio.PWMOut(board.GP22, frequency=5000)
ping4 = pwmio.PWMOut(board.GP11, frequency=400)
ping5 = pwmio.PWMOut(board.GP16, frequency=400)
ping6 = pwmio.PWMOut(board.GP5, frequency=400)
I am wondering if when the mask is defined, in the code, we are missing something. I cannot test that part of the code. However, if you select any pins in the same (8 2 Channel Slice) the code will fail. If we take the table 526 in the RP2040 datasheet, we could predict more or less which pins will fail. For example, for PIN 2, associated pins in the (8 2 Channel) will be 3, 8 and 9 and if we try in the following code all will have the same error.
import pwmio
import board
ping1 = pwmio.PWMOut(board.GP2, frequency=550)
ping2 = pwmio.PWMOut(board.GP19, frequency=550)
So I am not sure if this is related with the mask or the slice definition