Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Microcontroller USB
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 29-Apr-13 11:58am

1 solution

Rate this: bad
good
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;\
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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 584
1 Maciej Los 275
2 DamithSL 233
3 Sergey Alexandrovich Kryukov 209
4 BillWoodruff 200
0 OriginalGriff 6,803
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,421
3 Manas Bhardwaj 4,841
4 Maciej Los 4,330


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 29 Apr 2013
Copyright © CodeProject, 1999-2014
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