Academic Program

Modify main.c

Modify main.c

Step 9 - Add the following code to the end of the main.c file:

void main(void)
{
    // initialize the device
    SYSTEM_Initialize();

    while (1)
    {
         __delay_ms(250);
        LED_D2_Toggle();
    }
}

__delay_ms(250) is a delay function built into the XC8 compiler

The LED_D2_Toggle() is a macro generated by the MCC and its definition is located in the pin_manager.h file.

#define LED_D2_Toggle()             do { LATAbits.LATA4 = ~LATAbits.LATA4; } while(0)


This is a simple example of how the MCC generates a library of useful macros to make creating project code much easier and quicker.

Step 10 - Click on the Build Project icon (the hammer) to compile the code; you should see a BUILD SUCCESSFUL message in the output window of MPLAB X IDE.

Main_Build_Project.png
 

Output Window:

BUILD SUCCESSFUL