This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem using app_usbd on PCA10056

Hi,

I'm using SDK 13.0.0 and Softdevice s140 5.0.0-2alpha on my nrf52840-PDK. I tested the usbd_hid_generic and usbd_audio examples and they work fine, I can see the device being enumerated on my laptop when connected to USB.
Now I would also like to start the softdevice bluetooth stack and use the USB at the same time but it doesn't work, after a bit of digging through the code I've notcied that nrf_drv_power_init() will return a non zero value because softdevice is enabled
if (softdevice_handler_is_enabled())
{
return NRF_ERROR_INVALID_STATE;
}

So as a workaround I tried not to call nrf_drv_power_init() anymore and here is the code that I use to initialize USBD:
softdevice_handler_init(....) //somewhere I start the bluetooth stach which at some point calls this

ret = nrf_drv_clock_init();
ret = app_usbd_init(NULL);
app_usbd_enable();
app_usbd_start();

As you can see there is no call to nrf_drv_power_init(). When debugging I see that the code gets stuck in a while loop inside nrf_drv_usbd_enable() which is called by app_usbd_enable():
nrf_usbd_enable();
/* Waiting for peripheral to enable, this should take a few us */
while (0 == (NRF_USBD_EVENTCAUSE_READY_MASK & nrf_usbd_eventcause_get()))
{
/* Empty loop */
}

As you can see it enables USBD than polls NRF_USBD->EVENTCAUSE register waiting for USBD_EVENTCAUSE_READY. The problem is that this bit is never set so it gets stuck in this infinite loop.

Is there something else that I need to enable before this in order to get this bit set after I enable USBD ?

Thank you.

Parents
  • Hi

    I am using SDK 15.0, following project can reproduce this issue.

    ./examples/dfu/secure_bootloader/pca10056_usb/arm5_no_packs/secure_bootloader_usb_mbr_pca10056.uvprojx

    If you download this project by Keil-5 (CTRL-F5) to PCA10056 , program stop at main(), this issue can be 100% reproduced.

    Then if you free-run this project, and press reset key on PCA10056, this issue disappear.

    .. but, reset key sometimes doesn't resolve this issue...

    This is not a solution, just F.Y.R.

Reply
  • Hi

    I am using SDK 15.0, following project can reproduce this issue.

    ./examples/dfu/secure_bootloader/pca10056_usb/arm5_no_packs/secure_bootloader_usb_mbr_pca10056.uvprojx

    If you download this project by Keil-5 (CTRL-F5) to PCA10056 , program stop at main(), this issue can be 100% reproduced.

    Then if you free-run this project, and press reset key on PCA10056, this issue disappear.

    .. but, reset key sometimes doesn't resolve this issue...

    This is not a solution, just F.Y.R.

Children
No Data
Related