Well I must say that I'm still banging my head against USB CDC... I've tried this, the led does blink for 1 1/2 cycles and everything hangs and the pic does not enumerate.
Now, is it because USB is serviced before the device is attached?
I changed the interrupt from "ASM" to "PBP" (USBSERVICE is a PBP instruction).
Code:'******************************************************* 'Config fuses for PIC18LF14K50 '******************************************************* ASM CONFIG CPUDIV=NOCLKDIV ; CPU runing at full speed CONFIG USBDIV=OFF ; Low speed USB clock diviser disabled, not used here CONFIG FOSC=HS ; Use of High Speed crystal oscillator CONFIG PLLEN=ON ; Enable PLL multiplier, 12Mhz oscilator x 4 CONFIG PCLKEN=ON ; Primary clock source is enabled CONFIG FCMEN=OFF ; Failsafe clock off CONFIG IESO=OFF ; Oscillator switchover mode disabled CONFIG WDTEN=ON ; Watchdog timer on CONFIG WDTPS=512 ; Watchdog divider is 512 CONFIG MCLRE=OFF ; Disable MCLR pin, enable RC3 CONFIG STVREN=ON ; Stack full/underflow will cause reset CONFIG LVP=OFF ; Low voltage programming disabled CONFIG BBSIZ=OFF ; 512kW block boot size CONFIG XINST=OFF ; Extended instruction mode disabled ENDASM DEFINE OSC 48 DEFINE LOADER_USED 1 '******************************************************* 'Init for PIC18LF14K50 '******************************************************* 'Set ADC pins to digital operation ADCON0 = %00000000 'turn ADC OFF CM1CON0 = %00000000 'disabling comparator module 1 CM2CON0 = %00000000 'disabling comparator module 2 'Define pin function TRISA = %00000000 'PortA all digital output TRISB = %00000000 'PortB all digital output TRISC = %00000000 'PortC all digital output ANSEL = %00000000 'Disable analog input all pins ANSELH = %00000000 'Disable analog input all pins RedLED VAR PORTC.3 INCLUDE "cdc_desc.bas" ;--- Setup Interrupts ------------------------------------------------------ INCLUDE "DT_INTS-18.bas" ; Base Interrupt System INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler USB_INT, _DoUSBSERVICE, PBP, yes endm INT_CREATE ; Creates the Low Priority interrupt processor INT_ENABLE USB_INT ENDASM ;----[Initialise USB and Interrupts]---------------------------------------- PAUSE 100 ; Allow VUSB to stabilize USBINIT ; initialize the USB driver USBSERVICE ; service it once UIE = $7F ; enable USB interrupts UEIE = $9F ; enable USB Error interrupts ;----[Main program loop]---------------------------------------------------- Main: HIGH RedLED PAUSE 200 LOW REDLED PAUSE 200 GOTO MAIN ;----[Interrupt handler -- Service USB]------------------------------------- DoUSBSERVICE: USBSERVICE ; Run the SERVICE routines @ INT_RETURN END





Bookmarks