On an nRF52840 using SDK 15.3 and FreeRTOS 10
I've got both a PCA10056 dev kit and a custom board. I don't think I've got a hardware issue here but I'm running the usb_msc_pca10056 example on the dev kit and my own custom code on my custom board. Hard to mix the two but I've got it mostly the same... the example code is bare metal without an RTOS on it. I need to run RTOS on my code for other reasons and mostly because the USB portion is a small part of what I need to do.
What I've done is to take the example code and port it into my thread that runs the USB. In the end I want to run both CDC and MSC on SD cards but to simplify this what I've done is to run BOTH of these code sets with only msc and that only with the empty device on it. I'm just checking for windows enumeration of the things.
On the example code on the dev kit, this works fine. I get like one USB APP_USBD_EVT_DRV_RESET through usbd_user_ev_handler() and it enumerates immediately and stably on Win 10 showing the USB drive.
On my board (which works with CDC only just fine, BTW) and using substantially the same code for msc on it but in a FreeRTOS thread, this thing gets tons of APP_USBD_EVT_DRV_RESET (anywhere between 5 and constant) and enumerates on Win10 and then goes away and comes back and eventually comes back to a stable state.
Investigating this has something to do with the wait loop and I suspect time around that.
The example code is basically:
while (true)
{
while (app_usbd_event_queue_process())
{
/* Nothing to do */
}
/* Sleep CPU only if there was no interrupt since last loop processing */
__WFE();
}
while my code is essentially:
for (;;)
{
/* Waiting for event */
while (app_usbd_event_queue_process())
{
/* Nothing to do */
}
ulTaskNotifyTake(pdTRUE, 1);
}
So my question here is that this works nicely in CDC without issues. What I'm guessing is that the timing requirements of msc are very much tighter and running this in a thread is way harder to do reliably. Has anyone got some experience with running msc in FreeRTOS like this? Can it be done?