Finally I kept My ADC Working. Fully not tested I can say its working.
I have got some clues from the link below, installed MPLABX and kept it working first, then some comparisons to make it work.
https://www.microchip.com/forums/m757012.aspx
I would like to mention the changes I made so that it might become handy some one some time.
I used Complier - C30v3.31, MPLABv8.88
If you want to use 16 bit ADC using C30 complier.
1. Register Changes -
VOSCAL as SDOFFCAL
SDRDY as SDRESRDY
CHOP as CHOPSEL
** Description of CHOP is not given, in manual it written, enable it for best use.
2. I have given connections to the pins SVdd(sigma Vdd), Svss(sigma Vss) , Ch1+ & Ch0+ to adc input channels with a 0.1 uF capicator in parallel, Ch1- and Ch0- grounded. Please refer to Manual "Microchip - DS50002172A - page 32"
3. buffer which similar to ADCbuf is SD1RESH(16bit value) if your are using 16 bit or 8 bit rounding result option using register RNDRES. If you are using 24 bit rounding result then you have to use SD1RESH and SD1RESL. Here I used 16 bit rounding result.
3. for calculating offset
SDOFFCAL = 1, SDCH = 2/3 based ch0 or ch1+ used.
then the value received on SD1RESH is the offset.
4. for calculating SD_gain = EXPECTED_MAX_VALUE / (maxvalue - offset)
SD1RESH value when SDOFFCAL = 0, SDCH = 2/3 based ch0 or ch1+ used is the EXPECTED_MAX_VALUE.
SD1RESH value when SDOFFCAL = 0, SDCH = 1 is the maxvalue.
5. Measure channel when SDOFFCAL = 0 and SDCH = 2/3 based ch0 or ch1+ used.
The value in the buffer keeps varying from 0 to EXPECTED_MAX_VALUE.
Its regarding the example mentioned in Manual Microchip-DS00001607A-page 4.
You can use adc_interrupt as well apart from the example mentioned.
6. calibratedadcvalue = (SD1RESH -offset)*SD_gain
DC voltage I calculated (float)(calibratedadcvalue*(operating voltage/EXPECTED_MAX_VALUE))
I will update with the comparison of adc resolution w.r.t 12 bit and so on.
Regards,
Raady.