So I wrote the following function to get an ADC read in a program on an ATtiny13(a)
uint16_t adc_result (void) //return the current ADC value, the function will wait until the a conversion has ended. { uint16_t result; while( ADCSRA & (1<<ADSC)); // Wait until ADC conversion is complete.. result = ADCW; return result; }
I'm not getting expected behavior from my program and I think the culprit is dodgy ADC values because of my use of ADCW. Now someone told me that ADC or ADCW was something built into the compiler that I could use to automatically get the 16 bit reading of both ADCH and ADCL registers in one 16 bit value. Is this the case or should i read the ADCL/H registers and add them myself ?