AT90S2313-4052-Analog Mux-Demux
This project demonstrates the usage of Analog Comparator of AT90S2313. This project uses one Dual channel Analog Multiplexer / Demultiplexer and one AT90S2313 Microcontroller. Analog Mux / Demux does the channel selection and the output is given to the Microcontroller. The Analog Comparator compares the input values on the positive input AIN0 and the negative input AIN1. When the voltage on the positive input AIN0 is higher than the voltage on the negative input AIN1, the Analog Comparator Output, ACO is set (one). In this project when ACO is set to ‘One’, the Microcontroller will output ‘7F’ and when ACO is set to ‘Zero’, the output will be ‘00’.
The program is as shown
#include AT90S2313.h
int main(void)
{
unsigned int i;
DDRD = 0xFF // here the PORTD is used as the output port.
repeat:
for( i = 0x0 ; i < 0xF ; i++)
{
// ACSR - Analog Comparator Control and Status Register
// ACO (Analog Comparator Flag) flag in the ACSR register is set one
// If ACO flag is set one then 0x7f is sent to the output (PORTD).
// If ACO flag is set to zero then zero is sent // If ACO flag is set to zero then zero is sent through output port (PORTD).
if (bit_is_set(ACSR, ACO))
{
PORTD = 0x7F;
}
else
{
PORTD = 0x00;
}
}
goto repeat;
return 0;
}