Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

reading from 3 diferent ADC PORT,atmega88

Status
Not open for further replies.
But i'm returning the ADCH...

- - - Updated - - -

Yes,it work both ways...How i set it to left shifted result on your function?

By the way thank you for the help.
 

I'm not sure you understand what you are doing

Normally the ADC result is right justified, this means that the result can be in the range 0-1023 (16bit result)
Code:
0 to 0b0000001111111111
In this case read ADCW to get the 10 bit result


If you chose to set the result to be left justified, this would give the following 16bit values
Code:
0 to 0b1111111111000000
which is basically 0 to 65472 , the first value after 0 is 0b0000000001000000 which is decimal 64.
In this case read ADCH to get the 8 bit result

Select one of the two formats and read accordingly

- - - Updated - - -

The first function I gave you (read_adc) is for right shifted result and returns 10bit

The second function I gave you (read_adc8) is for left shifted result and returns 8bit

The left or right shift must be set by your initialization code, my functions don't change that setting
 

I did what you said ,and it worked just has i want,tank you so much.
Cheers from Portugal.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top