In a self-powered USB device what should VBUS pin of the USB connector connected to? Can it be left unconnected?
As per the USB specification, "Devices may not provide power to the pull-up resistor on D+/D- unless VBUS is present. When VBUS is removed, the device must remove power from the D+/D- pull-up resistor within 10 seconds” (section 7.2.1). The only way for a self-powered device to differentiate between a disconnect and a suspend is to monitor VBUS line. This can be done by monitoring VBUS at the USB connector through a GPIO. Following is simplified form of the implementation in CY4611 reference design (based on FX2)
// If VBUS is present we need to connect to the bus else we disconnect
USBCS |= bmDISCON;
USBCS &= ~bmDISCON;
Here VBUS is monitored through a GPIO and VBUS_PRESENT get constantly updated based on the presence of VBUS.