//Toggling 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 //PTJ1 is used to allow LEDs of PORTB to show the data (See Page 24 of Dragon12+ Doc) //Modified from Example 7-7 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. #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 since LEDs are connected to it DDRJ = 0xFF; //PTJ as output to control Dragon12+ LEDs PTJ=0x0; //Allow the LEDs to display data on PORTB pins for(;;) { PORTB = 0x55; MSDelay(500); //1/2 sec delay PORTB = 0xAA; MSDelay(500); } } //millisecond delay for XTAL=8MHz, PLL=48MHz //The HCS12 Serial Monitor is used to download and the program. //Serial Monitor uses PLL=48MHz void MSDelay(unsigned int itime) { unsigned int i; unsigned int j; for(i=0;i