Skip to content

USBMIDI crashes on XIAO BLE Sense (mbed enabled core) when the board is powered but has no USB connection #1066

@putzlicht

Description

@putzlicht

Hello,

I am using a XIAO BLE Sense (NRF52840) board to map IMU data into MIDI CC.
Yes I know this might be special topic because of the "core", so this is for information only.

Long story short. Except for one case, everything is working fine.
If the board is powered by an active USB hub but there is no PC on the other side,
then it hangs after a few attempts to send something.

The problem does not occur with the same code running on a Teensy LC for example.
So this is NOT a general problem with the library.
What I've already tried to do is figure out where it's hanging. If the code only runs update() without sendCC(), the problem does not occur. But that's probably because update() doesn't do anything if there's nothing to send...

The code simply repeats sending a CC and flashes the onboard LED to check if the board is still running.

#include <Arduino.h>
#include <Control_Surface.h>

USBMIDI_Interface midi_usb;

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
    midi_usb.begin();
}

void loop() {
    static uint32_t testtime;
    static boolean  teststate;

    if (millis() - testtime > 250) {
        testtime = millis();
        teststate = !teststate;
  
        if (teststate) {
            midi_usb.sendCC((1, Channel_1), 127);
            digitalWrite(LED_BUILTIN, LOW);
        } else {
            midi_usb.sendCC((1, Channel_1), 0);
            digitalWrite(LED_BUILTIN, HIGH);
        }
        midi_usb.update();
    }
  
}

If anyone out there knows how to prevent this, I would be very grateful :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions