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)
{
// Add your application code
if (Switch_GetValue() == 0)
{
LED_SetHigh();
}
else
{
LED_SetLow();
}
}
}
The Switch_GetValue(), LED_SetHigh() and, LED_SetLow() are #define's and macros that were generated by the MCC. Their definitions are located in the pin_manager.h file.
#define Switch_GetValue() PORTBbits.RB4
#define LED_SetHigh() do { LATAbits.LATA4 = 1; } while(0)
#define LED_SetLow() do { LATAbits.LATA4 = 0; } while(0)
This is a simple example of how the MCC generates a library of useful functions to make creating project code much easier and quicker.