//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 //Modified and tested by Mazidi from Example 7-7 of Mazidi & Causey HCS12 textbook //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 MSDelay(unsigned int); void main(void) { /* put your own code here */ unsigned int size=300; DDRT = 0xF0; //PT7-PT4 as output since LEDs are connected to it for(;;) { PTT = 0x50; MSDelay(size); PTT = 0xA0; MSDelay(size); } } //j is for 1 msec delay. Not Measured by Scope yet //Use Scope and modify j to get an exact value for 1 msec void MSDelay(unsigned int itime) { unsigned int i; unsigned int j; for(i=0;i