[an error occurred while processing this directive]
|
/* ADC Control and Status Register bit definitions */#define ADEN_BIT (1<<7)
#define ADSC_BIT (1<<6)
#define ADFR_BIT (1<<5)
#define ADIF_BIT (1<<4)
#define ADIE_BIT (1<<3)
#define ADPS2_BIT (1<<2)
#define ADPS1_BIT (1<<1)
#define ADPS0_BIT (1<<0)static char _channel;
//
// ** InitADC - the ADC initialization routine
//
void InitADC(void)
{
//
// PORTC is used as input analog port
//
DDRC = 0x00; // Set PORTC_channel = 0; // Start at channel 0
ADMUX = 0;
ADCSR = ADEN_BIT | ADSC_BIT | ADIE_BIT | 0x07;
}//
// ADC interrupt handler
//
#pragma vector=ADC_vect
__interrupt void ADC_Int(void)
{
char _byte = (ADC >> 2); // Get the data
char volatile *_pt = &Channels[Page][_channel];if (*_pt != _byte)
*_pt = _byte;
if (++_channel > 5) // Update channel number
_channel = 0; //
ADMUX = _channel; //
ADCSR |= ADSC_BIT; // Restart the conversion
}
E-mail: info@telesys.ru