Subversion Repositories MK3Mag

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/tags/V0.4/analog.c
0,0 → 1,30
/*############################################################################
 
############################################################################*/
 
#include "main.h"
 
//############################################################################
//Init ADC
void ADC_Init(void)
{
ADMUX = 0;
ADCSRA = 0x87;
ADMUX = 0;
ADCSRA |= 0x40; // Start Conversion
}
 
 
unsigned int MessAD(unsigned char channel)
{
unsigned int messwert = 0;
ADMUX = channel;
ADCSRA |= 0x10; // Clear Ready-Bit
ADCSRA |= 0x40; // Start Conversion
while (((ADCSRA & 0x10) == 0));
messwert = ADCW;
return(messwert);
}