RP2040 "not connected" to USB unless using long sleep calls

I have a project in which I'm running somewhat tight loops on both cores, using the FIFO to share data between them. I have some delayMicroseconds() calls in both loops.

Now I need to increase performance, so I have lowered the delay times, which causes the Arduino IDE to tell me the RP2040 is "not connected" or, in some cases with slightly longer delays, it shows up as connected, but an upload will not succeed, so I have to reset it to boot from USB, upload any other sketch and then upload my program again.

I have tried replacing the delays with calls to sleep_us() with no avail.

Is there anything else I can do to assure that I will keep USB connectivity, like a regular check or poll? Or is it just about long enough delays?

Just to add: I was also wondering why it doesn't seem to be enough to raise the delay times on one of the cores only. Both cores seem to need long delays in order for USB to function. I would assume that core 0 handles USB?

Apparently this can be mitigated by replacing the sleep/delay calls with busy_wait_us_32().

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.