System is Mega48PA, 4.6864MHz powered by 4.2V Lipo and charged by USB. It has 2 digit LED multilplexed and TXd comms at 1200 baud for debug.
AVcc is connected to Vcc(+100nF) and AREF is decoupled with 100nF. The system also has 3 buttons and an I/R transmission system with DOW 8 bit CRC checking.
Everything works just fine, but for the life of me, I can't get the ADC system to give me any sensible results. I get a few odd random meaningless readings, then the ADC gives a stream of constant readings.
Those readings won't change if I vary the input voltage...
There is a 39K from Vcc to ADC channel 7 then a 10K from there to PD2 which I pull low to activate the potential divider.
I calculated expected ADC values in the range of 0xB4 to 0xC7 using 1.1Vref and 8 bit resolution
In the code, I have left out the delay routine and the comms transmit.
Can someone give me a sanity check on the ADC code and point me in the right direction.....( I'm 99% certain there isn't a hardware issue)
I also tried reading the temperature Mux=8 with the similar results- no change in ADC value when I heated up the chip...
BATTERY: CLR TEMP STS ADCSRB,TEMP LDI TEMP,0xC7 ;1.1v REF;8 BIT ANS;CHANNEL 7 STS ADMUX,TEMP LDI TEMP,0XC6 ;ADEN,START,clk/64 STS ADCSRA,TEMP ADCWAIT: LDS TEMP,ADCSRA ANDI TEMP,0x10 ;TEST ADIF BIT BREQ ADCWAIT LDS TEMP1,ADCL ;GET LOW 8 BITS FROM ADC RCALL SENDCHR ;SEND TO UART RCALL DELAY ;WAIT 300mS RJMP BATTERY ;REPEAT