Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
CSS
Good evening,

The device under test is MicroChip USB Starter Kit 2.

The problem began appearing after adding some SPI initialization code to HID - Custom Demo program from 10-15-2012  microchip solutions framework.

Before the code was added everything in the demo worked perfectly

Code added was the following: right after
int main(void)
{

<pre>
int rData;
 //IEC0CLR=0x03800000; // disable all interrupts
 SPI1CON = 0; // Stops and resets the SPI1.
 rData=SPI1BUF; // clears the receive buffer
 IFS0CLR=0x03800000; // clear any existing event
  IPC5CLR=0x1f000000; // clear the priority
 IPC5SET=0x0d000000; // Set IPL=3, Subpriority 1
 IEC0SET=0x03800000; // Enable RX, TX and Error interrupts
 SPI1BRG=30; // use FPB/4 clock frequency
 SPI1STATCLR=0x40; // clear the Overflow
 SPI1CON=0x8260; // SPI ON, 8 bits transfer, SMP=1, Master mode



Immediately, after this was added, MPLabX began reporting

No source code lines were found at current PC 0x9d006474
the hex number changed depending on where I put the initialization code, but it never got past USBDeviceAttach();

Why is it that SPI is interfering with USB functionaly?

Notice that I commented out the line suggested by the FRM, assuming that this is the cause of those issues, but it was not.
//IEC0CLR=0x03800000; // disable all interrupts


Please let me know how this problem may be resolved.

Thank you,
Posted

1 solution

I found a solution to the problem, I don't know if it's a bug to the Microchip USB stack


But I added a line inside USBDeviceAttach(void)

IEC0CLR=0x03800000; // // disable all interrupts

Right before

USBEnableInterrupts(); //Modifies global interrupt settings




which is defined as:

Collapse | Copy Code
#define USBEnableInterrupts() {\
IEC1SET = USBIE /*0x02000000*/;\
IPC11CLR = 0x0000FF00;\
IPC11SET = 0x00001000;\
INTEnableSystemMultiVectoredInt();\
INTEnableInterrupts();\
}




Since then everythign worked perfectly.

I will submit this to Microchip and hopefully it will help someone down the line if they run into the same problem
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900