Header Files

Header files listed in alphabetical order. Files are denoted as either (AVR) or (PIC32) specific, if they apply to both platforms they are marked as (AVR|PIC32). For headers that are marked (AVR|PIC32) they can be either “generic” or “ported”. Generic files will work on either platform without modification where ported files are different for AVR or PIC32.

avr/interrupt.h (AVR)

avr/io.h (AVR)

avr/progmem.h (AVR)

avr/pgmspace.h (AVR)

Tools to access program space of the AVR processor, not needed on PIC32, but some macros can be used in its place to make AVR code run on a PIC32. <source>
  1. if defined(__PIC32MX__)
   // neither PROGMEM or PSTR are needed for PIC32, just define them as null
   #define PROGMEM
   #define PSTR(s) (s)
   #define pgm_read_byte(x)	        (*((char *)x))
   #define pgm_read_byte_near(x)	(*((char *)x))
   #define pgm_read_byte_far(x)	(*((char *)x))
   #define pgm_read_word(x)    	(*((short *)x))
   #define pgm_read_word_near(x)	(*((short *)x))
   #define pgm_read_workd_far(x)	(*((short *)x))

   #define	prog_void	 const void
   #define	prog_char	 const char
   #define	prog_uchar	 const unsigned char
   #define	prog_int8_t	 const int8_t
   #define	prog_uint8_t	const uint8_t
   #define	prog_int16_t	const int16_t
   #define	prog_uint16_t	const uint16_t
   #define	prog_int32_t	const int32_t
   #define	prog_uint32_t	const uint32_t
   #define	prog_int64_t	const int64_t
   #define	prog_uint64_t	const uint64_t
  1. else
  2. include <avr/pgmspace.h>
  3. endif


The start of all good programming sessions.





plib.h (PIC32)

Contains type definitions for PIC32 registers.


Servo.h (?)

SPI.h (AVR|PIC32) ported

Library to provide SPI communications.

stdint.h (AVR|PIC32) ported


wire.h (?)

wiring.h (?)

WProgram.h (?)

VN:F [1.9.22_1171]
Rating: 7.0/10 (3 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 1 vote)

The MPIDE Compiler for PIC32

Note: Information in this post applies to MPIDE, which has been deprecated. The recommended IDE for chipKIT core is now Arduino IDE or UECIDE. MPIDE still offers support for legacy code. For more information about MPIDE, please visit the legacy Install Page.

This is a fork of the compiler from about October 2010. So it’s ahead of the Microchip MPLAB C32 v1.12 release, but behind the upcoming C32 v2.00 release. Basically it’s similar to C32 v1.12, but updated to GCC 4.5.1. Also, the default linker scripts are modified to work with the chipKIT bootloader. There are no optimization restrictions in this build, but it will likely be updated less often than the official MPLAB C32 compiler.

Source code: https://github.com/chipKIT32/chipKIT-cxx

MPIDE Compiler optimisation

Currently, MPIDE is configured to call the compiler with the -O2 optimization option. The -O2 set of optimization usually results in a nice balance between code size and speed. However, there are some instances where you want to sacrifice code size (use more FLASH memory) in order to get more speed. Luckily, Rick has introduced features in MPIDE that makes changing the default compiler options easy to change.

To change the optimization level:

1. Open the /hardware/pic32/platforms.txt file in your favorite text editor.
2. Find the lines beginning with pic32.compiler.c.flags and pic32.compiler.cpp.flags. 
   In those lines, you should see a compiler optimization option, -O0, -O1, -O2, -Os, or -O3.
3. Change the optimization level option to the desired level, as listed below.
4. Save platforms.txt
5. Restart MPIDE.
Optimization levels
-O0 - Disable optimizations
-O1 - Reduce code size and execution time, without performing any optimizations that take a 
      great deal of compilation time.
-O2 - Optimize even more. GCC performs nearly all supported optimizations that do not involve a 
      space-speed trade-off. As compared to -O1, this option increases both compilation time and 
      the performance of the generated code. (This is currently the default.)
-O3 - Optimize yet more. GCC optimizes for maximum performance at the expense of code size.
-Os - Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size.
It also performs further optimizations designed to reduce code size.

For example:

If you really want aggressive performance for your sketch, you could also add the -funroll-loops option. Note that this option almost always increases code size but it may or may not increase performance.

For example:

VN:F [1.9.22_1171]
Rating: 7.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Overview of the Build Process

This post is in response to questions about the build process. Some of you are asking very reasonable questions. However, this stuff is specifically hidden to make the entire system easy for the beginner. If you are a beginner, I would recommend ignoring these details to start with.

Nevertheless, to answer your questions, the build process in MPIDE is the same as it is for the original Arduino system. It compiles all of the files in the core/xxx folder, xxx is specified in boards.txt. Normally there is only one and for PIC32, it’s cores/pic32.

It also will compile files from the 2 libraries folders. The 2 locations for libraries are the main one in pic32/libraries–where officially supported libraries go–and the second optional libraries folder in your sketches folder, where you are supposed to put any libraries that you download from 3rd parties. The reason for the second folder is that if you download a new version of MPIDE (or Arduino), you won’t lose those third-party libraries, as happened in earlier versions of Arduino.

It copies all files from your sketch folder, the library folders to a temp folder. You can follow this entire process by holding down the SHIFT key and clicking on COMPILE (the button on the far left). Similarly you can hold down the shift button when you click UPLOAD and you will see the entire UPLOAD process. ONE IMPORTANT NOTE… HITTING UPLOAD ALSO COMPILES SO YOU DO NOT NEED TO DO BOTH.

The compile process uses gcc from a command line. Done differently in MPIDE was the code to drive the compiler; it was totally re-written and is driven by a file called platforms.txt, which spells out the entire compile and link process. In Arduino, this was hard coded and darn near impossible to change.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)