Click here to Skip to main content
13,140,231 members (47,705 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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)
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 29-Apr-13 10:58am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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;\

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100