simple one: adc_on_lcd, why is adcon1=0x82??

General discussion on mikroC.
Post Reply
Author
Message
gabriell
Posts: 1
Joined: 05 Dec 2010 10:35

simple one: adc_on_lcd, why is adcon1=0x82??

#1 Post by gabriell » 05 Dec 2010 10:47

Hello!

Let's just say that I'm kinda new with mikroC, I'm using 8.2 version and, in the following example
C:\Program Files\Mikroelektronika\mikroC\Examples\EasyPic5\P16F887\ADC_on_LCD
there is one line that I can't understand:

Code: Select all

  ADCON1     = 0x82;                       // configure VDD as Vref, and analog channels
because in pic's datasheet ADCON1 register:

Code: Select all

bit 7 ADFM: A/D Conversion Result Format Select bit
1 = Right justified
0 = Left justified
bit 6 Unimplemented: Read as ‘0’
bit 5 VCFG1: Voltage Reference bit
1 = VREF- pin
0 = VSS
bit 4 VCFG0: Voltage Reference bit
1 = VREF+ pin
0 = VDD
bit 3-0 Unimplemented: Read as ‘0’
so why do you assign 1 to a 0 bit, and why do you need the "Right justified" option??

Thanks for the help!

Sobrietytest
Posts: 619
Joined: 05 Jul 2008 06:05
Location: Thailand

Re: simple one: adc_on_lcd, why is adcon1=0x82??

#2 Post by Sobrietytest » 06 Dec 2010 11:42

The output from the ADC it 10-bit so you have the choice of acquiring the data like this: nnnnnnnn nn000000 (LJ) or like this: 000000nn nnnnnnnn (RJ), both instances will fill two bytes. Assuming that you are then going to do some calculations with those two bytes, which do you think would be easier, LJ or RJ?

Post Reply

Return to “mikroC General”