Last change
on this file since 10110 was 10109, checked in by lutz, 14 years ago |
niculin & dom debugged quite some stuff
|
File size:
804 bytes
|
Line | |
---|
1 | #include "atmega_adc.h"
|
---|
2 | #include "typedefs.h"
|
---|
3 |
|
---|
4 | void 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 | ADMUX |= 1<<ADLAR; //ADLAR =1 --> left adjust ac result in ADCH register --> 8bit resolution only.
|
---|
18 | ADMUX |= (0x1F & 0x06); //MUX = 0x06 --> Pin ADC6 = PA6 is used as ADC input pin.
|
---|
19 |
|
---|
20 | ADCSRA |= (1<<ADSC); // start 1st conversion
|
---|
21 |
|
---|
22 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.