Tachyon,
USBSERVICE is a PBP statement, not an ASM statement. So it can't be in an ASM/ENDASM block.
It must be like this ...Then add an underscore in the INT_Handler statement.Code:'----[Interrupt handler -- Service USB]-------------------------------------------------- USBServiceISR: USBSERVICE @ INT_RETURNYou can only have 1 USBINIT in your program.Code:'---[Interrupts List]--- ASM INT_LIST macro ;Source, Label, Type, ResetFlag? INT_Handler USB_INT, _USBServiceISR, ASM, yes endm INT_CREATE ENDASM
And there should never be a USBSERVICE after the interrupt has been enabled.
Interrupting a USBSERVICE to do a USBSERVICE can cause bad things to happen.
The following program works perfectly here on a LAB-XUSB with an 18F4550.Code:'---[Initialize Chip]-------------------------------------------------------------------- InitChip: PAUSE 100 USBINIT USBSERVICE UIE = $7F UEIE = $9F ; PAUSE 500 ; USBINIT ; USBSERVICE @ INT_ENABLE USB_INT ; USBSERVICEMake sure you have 0.1uF bypass capacitors from VDD to VSS.Code:'*************************************************************************************** ' Title: USB CDC and DT_INTS Testing ' CPU: 18F4458 ' Clock: 20 MHz External Clock ' '**************************************************************************************** ASM __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H ; __CONFIG _CONFIG1H, _FOSC_ECPLLIO_EC_1H & _FCMEN_OFF_1H & _IESO_OFF_1H __CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H __CONFIG _CONFIG3H, _CCP2MX_ON_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_OFF_3H __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L ENDASM DEFINE OSC 48 DEFINE NO_CLRWDT 1 DEFINE USB_BUS_SENSE PORTD,3 INCLUDE "cdc_desc.bas" INCLUDE "DT_INTS-18.bas" '---[Interrupts List]--- ASM INT_LIST macro ;Source, Label, Type, ResetFlag? INT_Handler USB_INT, _USBServiceISR, ASM, yes endm INT_CREATE ENDASM goto InitChip '----[Interrupt handler -- Service USB]-------------------------------------------------- USBServiceISR: USBSERVICE @ INT_RETURN '---[Initialize Chip]-------------------------------------------------------------------- InitChip: PAUSE 100 USBINIT USBSERVICE UIE = $7F UEIE = $9F @ INT_ENABLE USB_INT PORTA = 0 PORTB = 0 PORTC = 0 PORTD = 0 PORTE = 0 'setup port i/o TRISA = %00000000 TRISB = %11111111 TRISC = %00110000 TRISD = %00001000 TRISE = %00000000 'all dig ADCON1 = %00001111 'enable port b pullups INTCON2.7 = 0 Main: goto Main end
And some people say that you also need 0.1uF from the USB +5V to VSS, but I've never had to do that.





Bookmarks