// I/O register definitions for AT90S8535 #include // delay functions #include #define ADC_VREF_TYPE 0x20 // ADC interrupt service routine interrupt [ADC_INT] void adc_isr(void) { // The LEDs will display the 8 most // semnificative ADC bits PORTB=(int) (~ADCW); // 20ms delay delay_ms(200); // Start a new AD conversion ADCSRA|=0x40; } void main(void) { // Port B initialization PORTB=0xFF; // all outputs DDRB=0xFF; // all LEDs are initially off // ADC initialization // ADC Clock frequency: 57.656 kHz // ADC Interrupts: On ADCSRA=0xCF; // Global enable interrupts // Select ADC input 0 ADMUX=0; // Start the first AD conversion ADCSRA|=0x40; #asm("sei") // All the job is done by ADC interrupts while (1); }