I'm using the MC9S12C32 with HCS12. So far this is what I've come up with for ADC for the temp. sensor. Please, help I'm stuck!
**********************************************************
#include <hidef.h> /* common defines and macros */
#include <mc9s12c32.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12c32"
#define TC1MS 1996 //???????????
#define ATDCTL2_VAL 0xC0; //ATD pwr up, ffc, no et. trig., no intrpt
#define ATDCTL3_VAL 0x20; //(4) conversions / sequence
#define ATDCTL4_VAL 0x83; //8-bit res,(2) A/D clocks/sample, presclr(8)
#define ATDCTL5_VAL 0x31;
void main(void) {
char i;
volatile unsigned int atd_value;
ATDCTL2 = ATDCTL2_VAL;
for(i = 0; i < 20; ++i); //Generate a delay > 20 micro secs.
ATDCTL3 = ATDCTL3_VAL;
ATDCTL4 = ATDCTL4_VAL;
DDRT_DDRT1 = 1;
PTT_PTT1 = 1;
for( ; ; ) {
ATDCTL5 = ATDCTL5_VAL; //ADC initiated
while(ATDSTAT0_SCF == 0);
atd_value = (ATDDR0L + ATDDR1L + ATDDR2L + ATDDR3L) /4;
} /* wait forever */
}
**********************************************************