//Displaying ATD0 channel 5 on LEDs of PORTB in C Language for Dragon12+ Trainer Board //with HCS12 Serial Monitor Program installed. This code is for CodeWarrior IDE //Modified from Program 13-1C of HCS12 book by Mazidi & Causey //In Dragon12+ PLL=48MHz. 48MHz/2=24MHz, Divivde by 24 to get 1MHz for conversion freq. //ADC channel 5 (PAD5) is connected to Temp Sensor (U14A close to POT) //Slowly warm up (or touch) Temp Sensor to see changes on LEDs of PORTB. NOT TOO HOT or the board will be damaged #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void MSDelay(unsigned int); void main(void) { /* put your own code here */ DDRB = 0xFF; //PORTB as output DDRJ = 0xFF; //PTJ as output for Dragon12+ LEDs PTJ=0x0; //Allow the LEDs to dsiplay data on PORTB pins ATD0CTL2 = 0x80; //Turn on ADC,..No Interrupt MSDelay(5); ATD0CTL3 = 0x08; //one conversion, no FIFO ATD0CTL4 = 0xEB; //8-bit resolu, 16-clock for 2nd phase, //prescaler of 24 for Conversion Freq=1MHz for(;;) { ATD0CTL5 = 0x85; //Channel 5 (right justified, unsigned,single-conver,one chan only) while(!(ATD0STAT0 & 0x80)); PORTB = ATD0DR0L; //dump it on LEDs MSDelay(2); //optional } } void MSDelay(unsigned int itime) { unsigned int i; unsigned int j; for(i=0;i