I want to have an interrupt when data comes in the PIC. I cant see what I"m doing wrong :
initialise:
Code:
RCONbits.IPEN=1; // interrupt prio enable
PIE2bits.USBIE=1; // usb IE
IPR2bits.USBIP=1;//high interrupt
UIEbits.TRNIE=1;//Transaction Complete Interrupt Enable bit
UIEbits.ACTVIE=1;
INTCON = 0b11000000; // GIE and PIE enable
You have to wait before setting usb Interrupt wait till the PLL to lock. Can't tell if your doing that from your code
Clearing the ACTVIF bit before the internal
hardware is synchronized may not have an effect on
the value of ACTVIF. Additionally, if the USB module
uses the clock from the 96 MHz PLL source, then after
clearing the SUSPND bit, the USB module may not be
immediately operational while waiting for the 96 MHz
PLL to lock. The application code should clear the
ACTVIF flag
I use the PLLEN , so my xtal frequency is multiplied with 4. ( =48MHz). I'm using the USB microchip framework for low usb pin count. So i didnt have to manual set the bits of the USB registers. I didnt wait for the PLL to lock , I've changed the code now.
RCONbits.IPEN=1; // interrupt prio enable
PIE2bits.USBIE=1; // usb IE
IPR2bits.USBIP=1;//high interrupt
UIEbits.TRNIE=1;//Transaction Complete Interrupt Enable bit
UIEbits.ACTVIE=1;//Bus Activity Detect Interrupt Enable bit
INTCON = 0b11000000; // GIE and PIE enable
The weird thing is that the code doesnt jump to the high interrupt vector. Even when I remove the
'if (PIR2bits.USBIF==1){..}' the PORTC.3 has to light up (led).