adafruit / adafruit/Adafruit_TinyUSB_Arduino
rp2040 PICO arduino tinyUSB midi example midi_test crashes when simultaneously receiving and sending messages at (not too fast) speed
- Dominant language
- C
- Stars
- 654
- Forks
- 183
- PR merge metrics
- No merged PRs in 30d
Description
### Operating System
Linux
### Arduino IDE version
2.0.3
### Board
PICO rp2040 from RP
### ArduinoCore version
PICO/RP2040 community 2.7.0
### TinyUSB Library version
release
### Sketch & Compiled output (as attached txt files)
modified examples/adafruit/midi/midi_test
Added callback for handling incoming clock ticks
Output 1 byte sysex every 40 ms instead of noteon/off every 266 ms
Turned off midi thru
[midi_test.txt](https://github.com/adafruit/Adafruit_TinyUSB_Arduino/files/10398270/midi_test.txt)
[midi_test.ino.bin.txt](https://github.com/adafruit/Adafruit_TinyUSB_Arduino/files/10398272/midi_test.ino.bin.txt)
### What happened ?
The sketch works if i run it without sending any midi events. ie) just letting the pico send out a sysex every 40ms.
The sketch works fine if I comment out the sendSysex in the sketch (dont send anything from PICO) and send the PICO clock ticks every 80ms.
The sketch crashes when i do both at the same time.
Sometimes it crashes within a minute...sometimes an hour.
The crash stops the PICO sending data and also stops the PICO receiving data.
A full reboot of the PICO is required.
### How to reproduce ?
Upload the sketch to a RPI PICO rp2040 using arduino ide and community core.
Connect a daw or other midi producing program to the PICO and send it clock ticks at 30 bpm - 24ppq = about every 80ms.
I wrote a simple html file for testing that can be dropped onto a webMIDI compliant browser.
If you want to use that for testing then copy the below html to a file called maybe test.html and drop that onto chromium/brave/chrome/edge (probably wont work in firefox).
Note: the javascript in the html looks for a midi device called "PICO MIDI 1". Change the name if your device is named differently.
With the pico running launch or refresh the script running in the browser.
Wait for a few minutes or longer for a crash.
Here is a link to a text file called test1.txt containing the html i used for testing the PICO.
[test1.txt](https://github.com/adafruit/Adafruit_TinyUSB_Arduino/files/10398283/test1.txt)
Rename test1.txt to test1.html and drop the file on a webmidi compliant browser to test the pico.
### Debug Log
_No response_
### Screenshots

Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the modified examples/adafruit/midi/midi_test sketch and review the attached midi_test.txt and test1.txt files. Reproduce on an RP2040 using Arduino IDE with simultaneous MIDI clock reception and sysex transmission. Done means the PICO continues receiving and sending MIDI without crashing during the described test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, javascript
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100