Datasheet

PIC32MX Starter Kit User’s Guide
DS61144D-page 28 © 2009 Microchip Technology Inc.
EXAMPLE 3-1: PROJECT SOURCE CODE
#include <plib.h> // Adds support for PIC32 Peripheral library
functions and macros
void Delay(unsigned int count)
{
while(--count);
}
int main(void)
{
/* LED setup - Turn off leds before configuring the IO pin as output */
mPORTDClearBits(BIT_0 | BIT_1 | BIT_2); // same as LATDCLR = 0x0007
/* Set RD0, RD1 and RD2 as outputs */
mPORTDSetPinsDigitalOut(BIT_0 | BIT_1 | BIT_2 ); // same as TRISDCLR = 0x0007
/* endless loop */
while(1)
{
Delay(200000);
mPORTDToggleBits(BIT_0); // toggle LED0 (same as LATDINV = 0x0001)
Delay(200000);
mPORTDToggleBits(BIT_1); // toggle LED1 (same as LATDINV = 0x0002)
Delay(200000);
mPORTDToggleBits(BIT_2); // toggle LED2 (same as LATDINV = 0x0004)
};
return 0;
}