//Displaying ATD0 channel 5 (POT) on LEDs of PORTB in C Language for HCS12 MCU Module from Freesacle or Axiom. //This C code tests on-board POT of the MCU Module without the Project Board //HCS12 MCU Module comes with BDM and ready to work with CodeWarrior IDE //Modified from Program 13-1C of HCS12 book by Mazidi & Causey //In HCS12 MCU Module, XTAL=4MHz.4MHz/2=2MHz is the bus freq. //ATD0 channel 5 (AN05) is connected to RV1 Brown/White POT. //Make sure Jumper for RV1 is set. Also make sure the VB jumper for Power_SEL (next to power jack) is set since it is powered via USB cable //Change the POT to see the changes on LEDs of PORTB //In CodeWarrior, make sure you are in TBDML Mode before downloading //Press F7 (to Make), then F5(Debug) to downLOAD,and F5 once more to start the program execution #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void MSDelay(unsigned int); void main(void) { /* put your own code here */ DDRB = 0xF0; //PORTB as output ATD0CTL2 = 0x80; //Turn on ADC,..No Interrupt MSDelay(1); //optional ATD0CTL3 = 0x08; //one conversion, no FIFO ATD0CTL4 = 0xE0; //8-bit resolu, 16-clock for 2nd phase, //prescaler of 0 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