How to enable and disable USB connection when using nrf52840 DK?

Hello Nordic Support,

I am working on an application that logs data to SD card when disconnected from USB and appears as USB Mass Storage Class on host PC when connected to USB. Currently, this is how I am testing the application. During logging phase, the DK is powered from the JLink port. To check the SD card content, I disconnect the cable from JLink port and connect it to the USB port. Thjs approach is working fine.

Note that, my application is based on the example 'usb_msc_pca10056' example

What I would like to do is to power DK from the JLink port and also connect the USB cable to the host PC and control the USB connect/disconnect by changing the pull down of USB data lines. To achieve this, I changed USBD_POWER_DETECTION from true to false

#define USBD_POWER_DETECTION false

However, the application kept restarting. Can you please let me know how I can control the USB connect/disconnection from the host PC without physically disconnecting the USB cable?

Thanks,
Anusha

Related