PIC32MZ EC w/FPU (EF) Starter Kit on MEB II Detect USB Unplug
Using the hardware indicated, I want to be able to have a process running and when the USB is plugged in, pause the process while the USB is plugged in and then resume the process when it is unplugged. The problem is the VBUS is always powered if the board has power either through the USB connector or the external power. If the external power is not there then obviously the board shuts off. The code can detect that the USB is plugged in because it becomes configured, but unplugging it does not deconfigure the USB.
My application is a combination of the USB MSD demo and the USB SD card demo. My application writes data to a file on the SD card while running but when I plug in the USB I want it to stop writing to the file, close it and then allow the PC to use the SD card. When the card is ejected and USB is unplugged, I want it to resume storing data to the SD card.
Is there an issue with this hardware that won't let VBUS turn off and detach the driver?