Ernie Bautista

ATD using MC9S12XDT512

Discussion created by Ernie Bautista on Nov 18, 2010
Latest reply on Nov 18, 2010 by kef

Hello everyone.  I'm having problems collecting an analog voltage from an infrared sensor using the MC9S12XDT512.  I'm very familiar with the MC9S12C32, so I'm trying to suit my code to this other microcontroller.  I'm only using one channel and one infrared sensor.  I have a DMM connected to the infrared sensor so I am able to match the voltage variable with the correct output voltage of the infrared sensor.  Here's my code:


void main(void) {


   float voltage;


   ATD0CTL2 = 0b11000000;

   ATD0CTL3 = 0b00001000;

   ATD0CTL4 = 0b10000001;   // 8-bit resolution

   ATD0CTL5 = 0b00000000;


   while(1) {


      voltage = (5 * (float)(ATD0DR0H / 256));

      ATD0CTL5 = 0b00000000;





I've tested this code using the MC9S12C32 and its functional.  When I run this code using the MC9S12XDT512, it throws an error - voltage variable is always 0.  Any input and help would be appreciated.  Thanks in advance!