If we want to configure our AD converter so we had all 8 AD
Solution
Solution:
a) The question itself is wrong. We cannot configure the 8 A/D ports as analog by changing bits of ADCON1. We have to write to the ANSEL register (8-bit) as explained below.
Let the bits of ANSEL be AN7 - AN0,
To make a particular port as analog we have to right logic 1 to the corresponding ANSEL bit.
For example if we want to make port3 as analog , we have to make AN3 logic 1.
In the question it was asked to make all the ports as analog. For this we have to write \'11111111\' to ANSEL register.
b)ADCON0 register will have bits called ADCS1, ADCS0,CHS3,CHS2,CHS1,CHS0,GO/DONE,ADON
The purpose of the bits is explained below:
ADCS1,ADSC0 combinely selects clock frequency
CHS3 - CHS0 select the corresponding port for conversion.
GO/DONE is status register set or reset by the chip to indiacate ongoing process.
( 1 for conversion in process , 0 for completion)
ADON - to enable or disable the converter. ( 1 for enabling A/D , 0 for disabling)
To convert sample from channel 4 we have to make CHS3-CHS0 as \'0100\' and ADON as \'1\'.
