//Toggling PORTT in C Language for TWR-HCS12G128 Tower module using CodeWarrior //On TWR-S12G128 Tower module, 4 green LEDs are connected to PT7-PT4 //They are active LOW. Make sure the jumers for all 4 LEDs are set //This program uses Timer Overflow for Delay. //Two ways to control Delay size. (1)Prescaler value, (2)SIZE value //Modified by Mazidi from Example 7-7 and 9-28 of Mazidi & Causey HCS12 book //Use F7 to Make, F5 (Debug) to download, and F5 (Start) to run the program //In CodeWarrior,make sure you are in Open Source BDM when downloading and running. #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void BigTimerDelay(unsigned int); void main(void) { unsigned int SIZE=1; //one way to control Delay size DDRT = 0xF0; //PT7-PT4 as output since LEDs are connected to it for(;;) { PTT = 0x50; BigTimerDelay(SIZE); PTT = 0xA0; BigTimerDelay(SIZE); } } void BigTimerDelay(unsigned int ttime) { unsigned int i; TSCR1 = 0x80; //enable timer TSCR2 = 0x01; //Prescaler=1 (2nd way to control Delay size is using 0 to 7) for(i=0;i