Graham Morton

MC9S12XDT512 A2D Converter

Discussion created by Graham Morton on Jan 31, 2007
Latest reply on Feb 5, 2007 by Graham Morton
Hi im using the following initiaization for a single channel conversion 8 bit conversion on AN0. I have a 0-5v reference voltage and an input that lies between this range.

im using:

void A2Dsetup (void){

ATD0CTL2_ADPU = 1;
ATD0CTL2_AFFC = 1;
ATD0CTL2_ASCIE = 1;
ATD0CTL3_FIFO = 0;
ATD0CTL4_SRES8 = 1;
ATD0CTL4_SMP1 = 1;
ATD0CTL4_SMP0 = 0;
ATD0CTL4_PRS4 = 0;
ATD0CTL4_PRS3 = 0;
ATD0CTL4_PRS2 = 0;
ATD0CTL4_PRS1 = 1;
ATD0CTL4_PRS0 = 1;
}

Im also using

int res;
int getTemperatures(void){

ATD0CTL5 = 0x00;
while (ATD0CTL2_ASCIF == 0);
res = (int) ATD0DR1H;
return res;
}

Using The debugger in CodeWarrior i have noticed that the program runs till the "while (ATD0CTL2_ASCIF == 0)" It never moves beyond this point.

Any ideas what im doing wrong or ideas for how i can get it to work?

Thanks to anyone who has any ideas!

Outcomes