Skip to content

Freezes/race conditions when sending MIDI data outside of uClock's timer interrupts #130

@doctea

Description

@doctea

Please see midilab/uClock#30 for description and example sketch using uClock that results in freezes when trying to send USB MIDI data outside of the uClock timer callback.

https://github.com/doctea/USBHost_t36/tree/merge-interrupt-fix has a fix - it seems to work around this by adding checks in several places to ensure that interrupts were already enabled before re-enabling them again. That seems to be the important part of solving the problem in the example sketch.

However, the branch has some other little workarounds that I have to add in order to have it working correctly in my project - without them, my project freezes during initial startup. I also find that doing Serial.print() several times while interrupts are disabled and the serial monitor isn't connected causes my app to freeze, until the serial monitor is connected - as if we're getting stuck in a loop waiting for the USB serial data to be collected. Prefacing my calls to Serial.printX with if (Serial) works around this.
I haven't built a simple sketch to replicate those problems yet as my main project is fairly large and complicated, but I'll try and circle back round to this at a later date. Mentioning this here now to help document the problem(s), provide potential workaround, and in case its happening to anyone else or if someone with greater understanding of the library can deduce what's going on! :)

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