//Toggling PT5 of PORTT in C Language for TWR-HCS12G128 Tower module using CodeWarrior //On TWR-S12G128 Tower module, 4 green LEDs are connected to PT7-PT4 (LED1-LED4) //They are active LOW. Make sure the jumers for all 4 LEDs (LED1-LED4) are set //Modified and tested by Mazidi from Example 7-24 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; //delay size in msec DDRT = DDRT | 0b00100000; //PT5 as output (LED2) for(;;) { PTT = PTT | 0b00100000; MSDelay(size); PTT = PTT & 0b11011111; 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