In my previous post I mentioned that my audio interface crashes after a while. I also mentioned that my guess it is because of the non-scheduling my different USB transefers. So I did it.
I used the SOF (Start-of-frame) interrupt as my 1ms timebase.This interrupt has to be enabled in the USB device configuration part, because it’s disabled by default. In other words simply replaced my HAL_GetTick() function which is based on the counter incremented each 1ms in the SysTick interrupt. My similar function is the USB_GetTick() which is based on the counter incremented each 1ms in the USB SOF interrup.
This is the new waveform I have. The start of the HID report transfer is in a fixed time slot. It comes after 718us always. And it completes of course in the end of the frame.
I tested it with playing audio and sending a new report each 4ms in my main loop and it worked. I did not tested it with the MIDI also sending, but I will do later.
Just a note: I have only 10 lines of code in my main while(1) loop so far, everything works with DMA, and interrupts at this point. Of course I don’t have the MIDI stack and sophisticated software functions, but I think it’s impressive 🙂