4.7 main.c Modified Code
The main.c
template file has been edited as shown below. Some comments have been
removed.
Note:
<xc.h>
is automatically included by
"mcc_generated_files/mcc.h
"./*
(c) 2018 Microchip Technology Inc. and its subsidiaries.
<See generated main.c file for additional copyright information.>
*/
#include "mcc_generated_files/mcc.h"
adc_0_channel_t channel = ADC_MUXPOS_AIN1_gc;
/*
Main application
*/
int main(void)
{
/* Initializes MCU, drivers and middleware */
SYSTEM_Initialize();
//Enable ADC and start conversion
ADC0_Enable();
ADC0_StartConversion(channel);
while (1){
if (ADC0_IsConversionDone())
{
if(ADC0_GetWindowResult())
{
PORTF.OUTCLR = PIN5_bm; // clear PF5 - LED on
}
else
{
PORTF.OUTSET = PIN5_bm; // set PF5 - LED off
}
}
}
}
/**
End of File
*/