-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RP2040 PWMIO module throws All timers for this pin are in use when defining two or more pins #4143
Comments
@DavePutz Do you want to take a look at this and find my bug? |
hitting the same issue when using just two pwm's (16, 17) |
@tannewt - I'll take a look at it. |
Thanks @DavePutz! |
@tannewt - We are currently checking whether a PWM channel is in use and throwing an error if it is. That is why the reported error it hit when GPIOs 21 and 5 are both used - they share channel 2B. However, the datasheet says "The same PWM output can be selected on two GPIO pins; the same signal will appear on each GPIO.". So, should we just take out the check for channel re-use? |
@DavePutz No, lets not allow outputting the same channel to multiple pins because the api implies their duty cycle would be independent. |
@tannewt - Ok, I'll submit a PR for another issue causing the error (we throw the same error for 4 different conditions :-( and leave the channel check in. |
Finding this issue here just saved me a lot of heartache :) I didn't pay attention to the "two pins per PWM channel" thing until seeing this. |
oh so this is fixed? I thought the PWM channels could be freely mapped. Where did you find that table with the channel pairs? |
Table 526 on page 536 of the data sheet. Also in Table 290 on page 252. |
This was fixed by #4165 |
I am still getting "ValueError: All timers for this pin are in use" when using GP18 and GP19 as PWMOut. |
With the patch in, this script is working for me:
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)
print(pinred,pingreen,pinblue)
Note that if you choose GPIO pins that use the same channel (such as 5 and
21, or any pair
that differ by 16) you will still get the ValueError.
…On Wed, Feb 10, 2021 at 10:32 PM bhavithiran97 ***@***.***> wrote:
I am still getting "ValueError: All timers for this pin are in use" when
using GP18 and GP19 as PWMOut.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4143 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKEWLK2AKGMYSQGRTDA3S6NMWJANCNFSM4XF4LMKA>
.
|
What do you mean by patch in ? |
I think they mean “with the proposed changes incorporated”
…On Wed, Feb 10, 2021 at 9:48 PM bhavithiran97 ***@***.***> wrote:
What do you mean by patch in ?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4143 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADWE465QJJPA2IXXPMGZOYTS6NVTBANCNFSM4XF4LMKA>
.
|
Did you test again with 6.2.0-beta.2? It incorporates the #4165 fix. [edit: typo: 6.1.0 -> 6.2.0] |
Getting "ValueError: All timers for this pin are in use". I want to change the frequency in a function, both GP18 and GP19 to same frequency. How can I do that ? |
@Bhavithiran97 you can't, check out the table here: #4143 (comment) |
The CircuitPython API doesn't allow for two PWM outputs to share a variable frequency. Instead, variable frequency requires separate underlying hardware. On the RP2040 that means separate PWM slices. |
I can change both frequecy for GP18 and GP19 in MicroPython. I can't do it in CircuitPython ? |
No. frequency is dictated by the TOP value and clock divider which are shared for the two channels output from a PWM slice. CircuitPython prevents you from changing these values from a single output because it could lead to unexpectedly changing the frequency of the other channel. MicroPython doesn't check this for you. Therefore, in CircuitPython you need to use pins with separate slices for each output. (For audio playback check out |
Uses the same logic applied in 5b57ae9 to determine when to add .exe. See related: adafruit#3310, adafruit#3361, adafruit#3370, adafruit#4143, adafruit#5727.
Running Circuitpython 8.2.9 on Itsybitsy M4: This code: While this code: Does not: using the same pins, same configuration, only the order of assignment is different. |
Please file a new issue. This issue is about the RP2040. Not the SAMD51 "M4". |
New issue created: #8811. |
When using the following code, I am getting the error that all the timers are used for pinblue(GP19)
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
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
This code will pass
this will fail
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.
So I am not sure if this is related with the mask or the slice definition
The text was updated successfully, but these errors were encountered: