source: firmware/MSR/src/atmega_adc.c@ 17697

Last change on this file since 17697 was 10588, checked in by neise, 14 years ago
added MSR Firmware MSR is the little brother of FSC
File size: 859 bytes
Line 
1#include "atmega_adc.h"
2#include "typedefs.h"
3
4void atmega_adc_init(void)
5{
6//ADC einschalten
7 ADCSRA |= (1<<ADPS2) | (1<<ADPS1); // ADC_clk = 125kHz
8 ADCSRA &= ~(1<<ADPS0);
9 // normal conversion takes: 13 adc_clk cycles = 104us
10 // 1st conversion takes longer: 25 clk cycles = 200us
11 ADCSRA |= 1<<ADATE; // autotrigger enable
12 SFIOR &= ~(0xE0); //ADTS=000 --> free running mode
13 ADCSRA |= (1<<ADEN); // ADC aktivieren
14
15 ADMUX &= ~(1<<REFS0);
16 ADMUX &= ~(1<<REFS1); //REFS = 00 --> use external reference voltage.
17
18 //ADMUX |= 1<<ADLAR; //ADLAR =1 --> left adjust ac result in ADCH register --> 8bit resolution only.
19 ADMUX &= ~(1<<ADLAR); //ADLAR =0 10bit :-)
20
21 ADMUX |= (0x1F & 0x07); //MUX = 0x07 --> Pin ADC7 = PA7 is used as ADC input pin.
22
23 ADCSRA |= (1<<ADSC); // start 1st conversion
24
25}
Note: See TracBrowser for help on using the repository browser.