//Displaying Overflow Timer on LEDs of PORTB in C Language for Dragon12+ Trainer with Codewarrior //Modified from Example 9-28 in HCS12 book by Mazidi & Causey #include /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void main(void) { /* put your own code here */ unsigned char overflow = 0; DDRB = 0xFF; //PORTB as output DDRJ = 0xFF; //PTJ as output for Dragon12+ LEDs PTJ=0x0; //Allow the LEDs to dsiplay data on PORTB pins TSCR1 = 0x80; //enable timer TSCR2 = 0x04; //Prescaler=16 (Try 0-7 values to see changes on LEDs) for(;;) { TFLG2 = 0x80; while (!(TFLG2 & TFLG2_TOF_MASK)); //wait for Timer Overflow overflow = overflow + 1; //keep adding the overflows PORTB = overflow; //and dump it PORTB to see } }