//Toggling PTT5 using Chann 5 Timer (Output Compare option) on TWR-HCS12G128 Tower using CodeWarrior //PTT5 of PORTT is connected to green LED on TWR-HCS12G128 Tower board //Make sure the jumer for LED2 is set //Notice this is NOT using any Time Delay //Modified and tested by Mazidi from Example 9-29 HCS12 textbook by Mazidi & Causey //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 main(void) { unsigned int Tcount; TSCR1 = 0x90; TSCR2 = 0x07; //Prescaler=128. Change (0-7) for different rate of toggling TIOS = 0b00100000; //Output Compare option for Channel 5 TCTL1 = 0b00000100; //Toggle PTT5 pin option //Toggle LED on PT5 pin using Timer chan 5 for(;;) { Tcount = TCNT; Tcount = Tcount + 30000; //change this number to see chnage in toggling rate TC5 = Tcount; while (!(TFLG1 & TFLG1_C5F_MASK)); //while ((TFLG1 & 0b00100000)==0); //you can use this line instead } }