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

USB disconnect causing system reset

Software : C / GCC - SDK 15.0.0 - SD140 6.0.0 - building on multiple platforms. 
Hardware : nRF52840-DK (Q1AAC0) - and secondary testing on custom board using the Fanstel BT840 Module 

Whenever the chip is in low-power, and the USB is disconnected there is a system reset.

We're using POWERMANAGE_... for sysoff, wakeup
And in the case of including an event handler it's the 


1) No USB device, no USB handlers or events included. Enter low power via button push, plug in USB, unplug results in full system reset. 
2) USB Event Handler included : nrf_drv_power_usbevt_init() --> linked to custom power_usb_event_handler(nrf_drv_power_evt_t event)
-- but no other service (no ACM, MSD, etc...) 
-- Plug in USB (reaches NRF_DRV_POWER_EVT_DETECTED) puts device into sleep
-- Unplug never hits USB event handler NRF_DRV_POWER_USB_EVT_REMOVED

So no USB handler set up, reset, USB handler set up - reset. Happens on both boards.

Is there some flag deep in the sdk we need to unset in order to tell the chip not to reset on unplug or are we looking at something in hardware? 



Parents Reply Children
  • hi. looks like i have a similar problem on SDKv15.2 

    NRF_DRV_POWER_EVT_DETECTED is presented and i can process it BUT only when firmware is active. 

    my code is super simple. 

    switch (event)
    {
    case NRF_DRV_POWER_USB_EVT_DETECTED:
        NRF_LOG_INFO("USB power detected");
        if (!nrf_drv_usbd_is_enabled()) {
            if ( !POWER_ON() ) sleep_mode_enter();
        }
        break;
    case NRF_DRV_POWER_USB_EVT_REMOVED:
        NRF_LOG_INFO("USB power removed");
        if (!nrf_drv_usbd_is_enabled()) {
        if ( true ) sleep_mode_enter();
        }
    break;
    default:
    }

    it supposed to check whether program have been already running before the event.

    NRF_DRV_POWER_USB_EVT_DETECTED works perfect

    but NRF_DRV_POWER_USB_EVT_REMOVED can not be processed from sys_off even if there is always true as i put in example

    UPD: your link in a comment above is broken 

Related