Datasheet

8 FAQs, Tips, and Troubleshooting
8.1 My PIC32 project gets a run time exception.
What could be wrong?
There are several issues that could be causing the runtime exceptions in a PIC32 project. Here are some things to check
that might help you find the source of the issue.
1. Check to make sure that you have a heap size defined. The USB host stack uses dynamic memory allocation, thus needs
a heap size defined. To add a heap to the project, go to the linker settings. This can be found in the "Project->Build
Options->Project->MPLAB PIC32 Linker" menu in MPLAB 8. This can be found in the "File->Project Properties->(current
build configuration)->C32->pic32-ld" in MPLAB X.
2. If a heap size is defined you can use the general exception vector to trap the error and determine what address caused
the exception. This can be done using something similar to the following code:
#if defined(__C32__)
void _general_exception_handler(unsigned cause, unsigned status)
{
unsigned long address = _CP0_GET_EPC();
DEBUG_ERROR("exception");
while(1){}
}
#endif
This will catch the exception and lock the code in a while(1). From this point you can halt the code and look at the address
variable to see what address caused the exception. Use the disassembly listing to determine the corresponding line of C
code.
8.2 How do I debug without access to ADB?
Though the USB is connected to the accessory now instead of the IDE for debugging, you can still access the ADB interface
through a network. Please see http://developer.android.com/guide/topics/usb/index.html for more information about how to
set this up.
You might also consider using a USB analyzer to determine what is actually happening on the USB bus. Please refer to the
Debugging the USB connection section for more details.
Microchip's Accessory Framework for Android(tm) 46
46
8