Hi Squib,
I can't take credit for the idea. It's an option on the Microchip USB development board, and
in the USB C firmware.
There's no reason to enable the USB module if it's not attached, so it's not a bad idea to
add in.
Hi Squib,
I can't take credit for the idea. It's an option on the Microchip USB development board, and
in the USB C firmware.
There's no reason to enable the USB module if it's not attached, so it's not a bad idea to
add in.
Hi Bruce, thank you for your almost exelent and simple sollution. Almost exelent because it will cost me 1 I/O and I don't have one I/O left. I have made a mistake because after testing this code again it was working.
USBwriteStatus:
USBService
USBOUT 3, USBBUFFER ,CNT_UIT, exitusbwritestatus
exitusbwritestatus:
RETURN
However this sollution has a disadvantage because when the outgoing USBBuffer is full it will also goto "exitusbwritestatus" without sending the information via USB, so some status information from PIC to PC will be lost.
You should be able to determine if it's plugged-in or not by monitoring the usb_device_state variable.
Code:usb_device_state VAR BYTE EXT CONFIGURED_STATE CON EXT IF (usb_device_state = CONFIGURED_STATE) THEN ; OK to send ELSE ; Detached or Enumerating, don't try to send. ENDIF
DT
Hi Darrel, I've tried it however it is not working. I've used the following.
IF (usb_device_state = CONFIGURED_STATE) THEN
high dataled
ELSE
low dataled
ENDIF
During USB connection the dataled is on. However the status of the dataled will not change when the USB cable will be disconnected. When I connect the cable in, for short time the dataled will be turned off and within about 300msec it will be turned on. I think that the Led will be turned off during enumeration.
Do I something wrong why it is not working?
Hi Ronald,
I've done something similar before, but I didn't have a USB breadboard handy at the time I replied.
I've dug out the old mister_e usbdemo breadboard.
Blown off the dust with a half a can of "Dust-Off" ...
... and am taking a look.
Hoping I can figure it out.
DT
Ditto, Doesn't work for me either...
Cheers
Squib
Bookmarks