I have stumbled across a problem with my USB PIC application. I am using a PIC 18F2550 which works fine and has been programmed using PICBasic Pro. Basically the device needs to be standalone, but when connected to the USB port, it can transfer data to and from the PIC. As i say, this is all working fine, or so i thought !!

During development, the PIC has always been plugged into the USB port with the PC turned ON. Today i unplugged it and found that it no longer worked when it is unplugged from USB. I am guessing this is due to it looking for data on the USB, and when there is none it hangs.

Plug it back in, and all is fine.

Does anyone have reasonable experience with PICBasic Pro and these PICs. The base code was generated using EasyHID.

Obvioulsy i can send the code i have so far, but i think the problem lies in this DoUSBOut routine. Is there a way for it to say, if no USB connection RETURN.

Code:
' ************************************************************
' * wait for USB interface to attach                         *
' ************************************************************
DoUSBOut:
   USBBufferCount = USBBufferSizeTX              ' TX buffer size
   USBService                                    ' keep connection alive
   USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
Return
To clarify, I want the PIC to function normally whether the PC is ON or OFF and if the USB is connected or not, and only the sending / receiving of data to take place when I load the VB application.

Although this is not a data logger aplication, has anyone worked on a USB datalogger application. ie it collects data, but when it is plugged inot the USB it can then tranfer this data. I need it to be so that no user intervention is required to put it in USB mode.

Many thanks.

Steve