//Sounding the Buzzer on PT0 using Chann 0 Timer (Output Compare option) //PT0 of PORTT is connected to buzzer/speaker on Project Board //Notice this is NOT using any Time Delay //Modified by Mazidi from Example 9-29 of HCS12 book by Mazidi & Causey //On Student Project Board, PT0 of PORTT is connected to buzzer/speaker permanently. It is accessed by BZ jumper. //MAKE SURE jumper for BZ (buzzer) is set. BZ JUMPER is part of group of jumpers called UFEA right next to the Buzzer itself //This program toggles PT0 to sound the buzzer using Channnel 0 of Timer and not time delay method. //In CodeWarrior,MAKE sure you are in TBDML Mode before downloading //Press F7 (to Make), then F5(Debug) to downLOAD,and F5 once more to start the program execution #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void main(void) { /* put your own code here */ unsigned int Tcount; TSCR1 = 0x90; TSCR2 = 0x07; //Prescaler=128. Change (0-7) to hear different sound TIOS = 0b00000001; //Output Compare option for Channel 0 TCTL2 = 0b00000001; //Toggle PT0 pin option //Sound the Buzzer by toggling PT0 pin using Timer chan 0 for(;;) { Tcount = TCNT; Tcount = Tcount + 5000; //Also change the 5000 number to a differnt to hear different sound TC0 = Tcount; while (!(TFLG1 & TFLG1_C0F_MASK)); } }