chipKIT® Development Platform

Inspired by Arduino™

Libraries: PIC32 vs AVR

Created Sat, 14 Apr 2012 18:05:42 +0000 by JerryH


Sat, 14 Apr 2012 18:05:42 +0000

NOOB question: How does the compiler know to use the PIC32 or AVR libraries?

Example: I call up the following sketch in MPIDE 0023: C:\Program Files\mpide-0023-windows-20111221\hardware\pic32\libraries\Wire\examples\digital_potentiometer\digital_potentiometer.pde

If I switch the 'board' to Arduino UNO using the IDE menu (/tools/board/Arduino Uno), the sketch compiles without errors.

However, when I switch the 'board' to UNO32 (/tools/board/ChipKIT UNO32) I get errors that indicate that the compiler isn't using the PIC32 libraries:

In file included from C:\Program Files\mpide-0023-windows-20111221\libraries\Wire\utility\twi.c:23:0: c:\program files\mpide-0023-windows-20111221\hardware\pic32\compiler\pic32-tools\bin../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/include/avr/io.h:4:2: error: #error ******** This sketch or library uses AVR-specific code that may not work with the chipKIT platform. See this forum for more information on porting code to chipKIT [] ******** C:\Program Files\mpide-0023-windows-20111221\libraries\Wire\utility\twi.c:24:27: fatal error: avr/interrupt.h: No such file or directory compilation terminated.

The compiler isn't looking in the "\hardware\pic32" library, its still pointed to the default avr libraries. There's got to be a way for me to tell the compiler to use the libraries in that directory, but I don't know how to do this.


Sun, 15 Apr 2012 04:09:47 +0000

Well, I finally simply deleted the avr library files and copied the PIC32 library files to the location: C:\Program Files\mpide-0023-windows-20111221\libraries

...and I can now compile the code with the 'board' set to chipKIT UNO32.

Is this the only way to handle this? Or is there some way for the compiler to automatically 'know' where the proper libraries are?


Sun, 15 Apr 2012 17:06:58 +0000

Might want to try reinstalling MPIDE, it should pretty much work out of the box without having to change any directories. Also try loading the example in libraries\wire folder vs, hardware\pic32\libraries\wire. I tried both examples files and was able to switch them between uno and uno32 with no issues.