look, here is a interrupt handler of keyboard LED on 16C745 / 765
' Define interrupt handler
DEFINE INTHAND usbint
' Assembly language interrupt handler
asm
; W, STATUS and PCLATH registers already saved, save FSR
usbint movf FSR, W
movwf fsave
; Check interrupt source and vector there
movlw high ServiceUSBInt
movwf PCLATH
btfsc PIR1, USBIF
call ServiceUSBInt
btfsc PIR2, USBIF
call ServiceUSBInt
; Restore saved registers
banksel UIR
movf 0xC8,w
clrf STATUS
movwf kbdLED
movf fsave, W
movwf FSR
movf psave, W
movwf PCLATH
swapf ssave, W
movwf STATUS
swapf wsave, F
swapf wsave, W
retfie ; Return from interrupt
endasm
before the kbdLED should be defined in Picbasic static (important !):
kbdLED VAR BYTE bank0 system
on 18F Chips the code have to be placed in the USB interrupt routine.
LEDs are using the EP0 control transfere.
To get pc->pic communication use a component device with a HID + Keyboard interface.
Bookmarks