Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
312 | pangu | 1 | /*############################################################################ |
2 | |||
3 | ############################################################################*/ |
||
4 | |||
5 | #include "main.h" |
||
6 | |||
7 | //############################################################################ |
||
8 | //Init ADC |
||
9 | void ADC_Init(void) |
||
10 | |||
11 | { |
||
12 | ADCSRA = 0xA6; // Free Run & 1MHZ |
||
13 | ADMUX = 0; // Kanal 0 |
||
14 | ADCSRA |= 0x40; // Start |
||
15 | } |
||
16 | |||
17 | |||
18 | |||
19 | //############################################################################ |
||
20 | //Strom Analogwerte lesen |
||
21 | unsigned int getVcurr() |
||
22 | |||
23 | { |
||
24 | ADMUX = 0 | 0xC0; // Kanal 0, interne Referenz |
||
25 | SFIOR = 0x00; // Analog Comperator aus |
||
26 | ADCSRA = 0xD3; // Converter ein, single |
||
27 | ADCSRA |= 0x10; // Ready löschen |
||
28 | ADMUX = 0 | 0xC0; // Kanal 0, interne Referenz |
||
29 | ADCSRA |= 0x40; // Start |
||
30 | while (((ADCSRA & 0x10) == 0)); |
||
31 | ADCSRA = 0x00; |
||
32 | SFIOR = 0x08; // Analog Comperator ein |
||
33 | return(ADCW); |
||
34 | } |
||
35 | |||
36 |