Skip to content

RP2040 SPI transactions are interruptible by ctrl-C #4970

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

Closed
dhalbert opened this issue Jul 6, 2021 · 1 comment
Closed

RP2040 SPI transactions are interruptible by ctrl-C #4970

dhalbert opened this issue Jul 6, 2021 · 1 comment
Labels
bug busio rp2040 Raspberry Pi RP2040
Milestone

Comments

@dhalbert
Copy link
Collaborator

dhalbert commented Jul 6, 2021

CircuitPython version

7.0.0 latest, easily visible on MacroPad

Code/REPL

# code.py could be as simple as:
import time

i = 0
while True:
    print(i, "some text")
    i += 1
    time.sleep(0.1)

Behavior

The MacroPad display can become garbled if the code above is run, and then interrupted with ctrl-C, and then restarted with ctrl-D. Trash will appear on the right side of the display. Other more display-intensive programs can cause worse problems, like upside-down text, part of screen showing quickly-changing flickering text, etc.

Description

I have a hunch this is due to SPI display transactions being interruptible by ctrl-C. This code allows them to be interrupted:

if (mp_hal_is_interrupted()) {
if (dma_channel_is_busy(chan_rx)) {
dma_channel_abort(chan_rx);
}
if (dma_channel_is_busy(chan_tx)) {
dma_channel_abort(chan_tx);
}
break;
. There is other code elsewhere in that file that also allows interruptions.

The interruptions probably allow junk to be sent to the display: data interpreted as commands, etc. Perhaps this is in combination with the D/C line getting out of sync.

May be related to adafruit/Adafruit_CircuitPython_DisplayIO_SH1106#3.

Additional information

From @kattni (different display garbling from a different program):

image

Animation: https://cdn.discordapp.com/attachments/327298996332658690/862041401708904468/macropad_display_glitch.gif

@dhalbert dhalbert added bug busio rp2040 Raspberry Pi RP2040 labels Jul 6, 2021
@dhalbert dhalbert added this to the 7.0.0 milestone Jul 6, 2021
@dhalbert
Copy link
Collaborator Author

Fixed by #4974.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug busio rp2040 Raspberry Pi RP2040
Projects
None yet
Development

No branches or pull requests

1 participant