tommyjt24
11-09-04, 07:49 AM
Hey everyone, Just wanted some thoughts on why my ADC doesnt read zero with nothing pluged onto the An pins??? I'm using the H6 so I know it can read 0-Vref, Even with a pin pluged in and a variable resister(a pot) the voltage I get doesnt ever go below what i calculate out as 2.4v. So I have lost a whole range below 2.4v. I have the pot hooked up to 3.3v pin on the board, J2 and have it hooked into the pot and then 100k resister to ground. the voltage on my meter reads from vref to 0 so I do not know why the An pins do not. Bellow is my code for setting up the ADC. then I just have a timer and when timer goes off I check my voltage. I check the voltage by polling for new data.
void initADCA(void)
{
*ADACR1 = 0x0202;//001(start)1(sync) set llmtie bit 9
//0000 interupts end of scan, zero crossing, low limit, high limit
//0000 differential inputs
//0000 once sequential, 010, loop sequential
*ADACR2 = 0x003D;//0000 0000 0000 [0DIV]
*ADAZCC = 0x0000;//[1:0] ZCE0 zero crossing enable
*ADALST1= 0x0000;//0000 0000 0000 0000 enables AN0
*ADALST2= 0x0000;//0000 0000 0000 0000
*ADADIS = 0x00F8;//[15:14] 00 normal mode, 01 test mode vref/2
//[7:0] enable 0, disable 1
*ADALLMT0= (2891<<3);//low limit of when we need to charge approx 5.5V
// *ADAOFS0 =0x0000;//offset to correct value 2891
*ITCN_GPR14 |= 0x0060; //set up interupt vector
}
void initADCA(void)
{
*ADACR1 = 0x0202;//001(start)1(sync) set llmtie bit 9
//0000 interupts end of scan, zero crossing, low limit, high limit
//0000 differential inputs
//0000 once sequential, 010, loop sequential
*ADACR2 = 0x003D;//0000 0000 0000 [0DIV]
*ADAZCC = 0x0000;//[1:0] ZCE0 zero crossing enable
*ADALST1= 0x0000;//0000 0000 0000 0000 enables AN0
*ADALST2= 0x0000;//0000 0000 0000 0000
*ADADIS = 0x00F8;//[15:14] 00 normal mode, 01 test mode vref/2
//[7:0] enable 0, disable 1
*ADALLMT0= (2891<<3);//low limit of when we need to charge approx 5.5V
// *ADAOFS0 =0x0000;//offset to correct value 2891
*ITCN_GPR14 |= 0x0060; //set up interupt vector
}