From: Jan "Yenya" Kasprzak Date: Fri, 8 Jun 2012 16:43:08 +0000 (+0200) Subject: ADC experiments X-Git-Tag: gedasymbols-20120913~67 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=1198700abdd06ef61ab82ed42b853dbfc21dd300;p=bike-lights.git ADC experiments --- diff --git a/lights.c b/lights.c index 0bedc53..49bf4ce 100644 --- a/lights.c +++ b/lights.c @@ -2,7 +2,7 @@ #include #include -char dbg[5] __attribute__((section(".eeprom"))); +uint16_t adcval EEMEM; int main(void) { @@ -15,12 +15,15 @@ int main(void) DDRB |= _BV( PB5 ); PORTB &= ~_BV( PB5 ); + ADCSRA = _BV(ADEN) | _BV(ADATE) | _BV(ADPS1) | _BV(ADPS0); + ADMUX = _BV(REFS1) | _BV(MUX0); + ADCSRB = _BV(REFS2); + DIDR0 = _BV(ADC1D) | _BV(AREFD); + + ADCSRA |= _BV(ADSC); _delay_ms(1000); - eeprom_write_byte(&dbg[0], TCNT1); - eeprom_write_byte(&dbg[1], OCR1C); - eeprom_write_byte(&dbg[2], OCR1D); - eeprom_write_byte(&dbg[3], TIFR); - eeprom_write_byte(&dbg[4], TCCR1B); + eeprom_write_word(&adcval, ADCW); + DDRA |= _BV( PA0 ); while( 1 ) { PORTA |= _BV( PA0 );