8.2 Transmit the Results
The ADC result will be read. If the result is under a specific threshold, the LED will be
turned on. Otherwise, it will be turned off. Then, the conversion result will be
transmitted through USART, as presented
below.
while (1)
{
while (!ADC0_resultReady());
if (ADC0_resultBelowTreshold())
{
LED0_on();
}
else
{
LED0_off();
}
adcVal = ADC0_read();
/* Transmit the ADC result to be plotted using Data Visualizer */
USART1_Write(START_TOKEN);
USART1_Write(adcVal & 0x00FF);
USART1_Write(adcVal >> 8);
USART1_Write(END_TOKEN);
}