-
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
rp2pio: Transfer up to 32 bytes before checking background tasks #4155
Conversation
@jerryneedell noticed that this problem affected strips short enough to not use the DMA peripheral, thanks for the hot tip! Instead of checking for background tasks after every byte transfer, try up to 32 transfers before attending to background tasks. This fixes the problem I was seeing on my 5-pixel circuit. Closes adafruit#4135.
Thanks -- I'll try this later today -- Credit goes to @gamblor21 for finding the DMA link to this issue. |
good teamwork - amazing! |
I agree yours is a better implementation. I did not want to remove the background tasks all together as I wasn't sure of any potential side effects. |
Sorry to report this still not working for me. using a 7 pixel jewel:
|
also ```Adafruit CircuitPython 6.2.0-beta.1-128-g5423e4966 on 2021-02-08; Raspberry Pi Pico with rp2040
pixel 0 is not responding properly. |
hmm -- I had an "Airlift" connected to the Pi - it was not being used, but now that I have disconnected it, I am so far not able to reproduce the issues -- more testing to do.... |
I have been unable to reproduce the issue with the Airlift disconnected.... |
To be fair, I had more that just the Airlift connected. I have not determined which was the culprit...yet ... I just assumed it was the Airlift -- perhaps hastily. With just the bare Pico -- my "jewel" is behaving very normally with this PR. |
@jerryneedell let's talk about this in the discord meeting today |
Tested with #4160 -- both are working for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested by @jerryneedell and @gamblor21.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion to simplify things. (I realize I'm a bit late. Thanks for fixing this!)
--rx_remaining; | ||
did_transfer = true; | ||
} | ||
if (!did_transfer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be clearer if you replaced the original if statements with while loops. That way you'd load up the 4 or 8 entry FIFO and then move on. 32 seems arbitrary and I'm skeptical you'd ever hit that many due to the FIFO size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose 32 because it was the DMA threshold. I didn't check the FIFO size at all! I'll open an issue suggesting the clean-up, but try to get to it next time I'm working in this code.
@jerryneedell noticed that this problem affected strips short enough to not use the DMA peripheral, thanks for the hot tip!
Instead of checking for background tasks after every byte transfer, try up to 32 transfers before attending to background tasks.
This fixes the problem I was seeing on my 5-pixel circuit.
Closes #4135.
I wrote this before seeing the simpler #4149. I think this MAY be a bit better than #4149, and here's why: Occasionally, background tasks and interrupts can immediately create new background tasks. This PR would ensure that up to 32 bytes were made available to the PIO peripheral before attending to them, while that one doesn't.