Hi DT,
Great! I tried this one and it works. Good one.
However, I've tried to incorp. it into an existing program and it doesn't work.
Your code seems to indicate that the USBSERVICE routine is continually called by the USB_int handler. How often does this interrupt? Only when it is plugged / unplugged or all the time?
The problem is that I'm servicing the USBSERVICE through a 1msec Timer1 interrupt handler and trying to read the flags in that interrupt but they don't set.
Code:
'---[TMR1 - interrupt handler]---------------------------------------------------
USB_SERVICE: ' COMES HERE 1msec TO SERVICE THE USB PORT
T1CON.0 = 0 ' TURN OFF TIMER
TMR1L = COUNTER1.byte0 ' RELOAD TIMER LOW
TMR1H = COUNTER1.byte1 ' RELOAD TIMER HIGH
IF IDLEIF THEN Plugged = 0
IF SOFIF THEN Plugged = 1
USBService ' KEEP USB ALIVE
T1CON.0 = 1 ' TURN ON TIMER
@ INT_RETURN
The way I see it is that SOFIF should always be set since I'm servicing USB every 1 msec untill I disconnect the USB cable.
I would do away with the Timer1 Interrupt altogether and use USB_INT but how often does the USB_int get called?
Cheers
Squib
Bookmarks