The input/output (I/O) pins on the microcontroller package are organized into groups of up to 16 pins. Each group is called a port. Ports are named in aphabetical order: Port A ... Port G. Each pin is tied to a bit in an internal register of the microcontroller. The registers are, in turn, mapped to memory locations within the CPU address space. This practice is called memory-mapped I/O.
The association between the pin names and corresponding bit locations is shown below, for Port D.
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
RD15 | RD14 | RD13 | RD12 | RD11 | RD10 | RD9 | RD8 | RD7 | RD6 | RD5 | RD4 | RD3 | RD2 | RD1 | RD0 |
The development board in the PIC32 Starter Kit has three LEDs and three switches connected to pins in Port D as shown:
LED | pin | SW | pin | |
---|---|---|---|---|
LED1 | RD0 | SW1 | RD6 | |
LED2 | RD1 | SW2 | RD7 | |
LED3 | RD2 | SW3 | RD13 |
The peripheral library is a high-level, C-language interface between the programmer and the peripheral devices of the PIC32 microcontroller.
The following include statement should be used to access the peripheral library. The file p32xxxx.h is automatically included as well.
#include <plib.h>
The following documents the basic macros and functions for using digital output and input pins:
Maintained by John Loomis, last updated 18 July 2008