//Get data from PTH DIP swiches and send it to PORTB in C Language for Dragon12 Plus Trainer Board //with HCS12 Serial Monitor Program installed. This code is for CodeWarrior IDE //On Dragon12+ Trainer board 8 LEDs are connected to PORTB and PTH is connected DIP Switches //Modified from Example 7-10 of Mazidi & Causey HCS12 book //Use F7 to Make, F5 (Debug) to download, and F5 (Start) to run the program //Make sure you are in HCS12 Serial Monitor mode when downloading and running. . //In DIP Switches up=1 and down=0 #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 for LEDs DDRJ = 0xFF; //PTJ as output for Dragon12+ LEDs PTJ=0x0; //Allow the LEDs to disiplay data on PORTB pins DDRH = 0x0; //Make PTH as input for DIP Switches for (;;) { unsigned char x; x = PTH; //get data from PTH DIP Switches MSDelay(1); //optional PORTB = x; //and send it to PORTB LEDs MSDelay(1); //optional } } void MSDelay(unsigned int itime) //millisec daly { unsigned int i; unsigned int j; for(i=0;i