I am using an RP240 mounted on an Adafruit Itsy-bitsy board. After successfully loading the bootloader (keeping the BOOT button pressed), I have loaded the Fade example from the recommended library. Everything works correctly. The problem occurs when I upload my own code that I have developed.
I press the load button and after correctly compiling said code, it is loaded onto the board with RP240. After this the USB device disappears and it is not possible to find it in the device manager in Windows 10.
Has anyone experienced this situation or been able to solve it correctly?
PS: I have checked the code on an Arduino UNO with ATmega328p and everything works fine as expected.
Use the BOOT and RST buttons to put the board into bootloader mode then upload a simple sketch such blink. The USB serial port should work again. There is something wrong with your sketch that is causing the USB serial port to fail.
Indeed the problem seems to be caused by the code in my sketch.
I have removed some functions and libraries and the remaining code has been able to load and execute correctly.
Now a new question arises. The point is, that, the complete code (the one I describe at the beginning of the post) works correctly with an Arduino UNO but not with an RP2040.
I think, that the library I removed causes the Serial USB to crash, but the code compiles correctly in the IDE.
Does the RP2040 have native USB? If so, part of the code that you upload is code (and variables) that detects the serial port opening and closing at 1200 baud to activate the boot loader.
Due to a memory issue in your code (e.g. writing outside the boundaries of an array), you corrupt it.