4.7 main.c Modified Code
The
main.c
template file has been edited as shown below. Some comments have been
removed.#include "mcc_generated_files/mcc.h"
/*
Main application
*/
void main(void)
{
// Initialize the device
SYSTEM_Initialize();
uint16_t volatile adcValue;
// If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts
// If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts
// Use the following macros to:
// Enable the Global Interrupts
//INTERRUPT_GlobalInterruptEnable();
// Disable the Global Interrupts
//INTERRUPT_GlobalInterruptDisable();
// Enable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptEnable();
// Disable the Peripheral Interrupts
//INTERRUPT_PeripheralInterruptDisable();
while (1)
{
// Start conversion (see 4.7.1 Select A/D Channel and Start Conversion)
ADCC_StartConversion(channel_ANA0);
// Wait (see 4.7.2 Wait for ADC to Compete)
while(!ADCC_IsConversionDone());
adcValue = ADCC_GetSingleConversion(channel_ANA0);
// Write to Port Latches (see 4.7.3 Write to Port Latches)
LATA = adcValue; // RA[4:7] = LED[2:5]
}
}
/**
End of File
*/