#include #ifndef TFLG1_C2F_MASK #define TFLG1_C2F_MASK 0x04 #endif unsigned int Tcount; void main(void) { TSCR1 = 0x90; TSCR2 = 0x00; TIOS = 0x04; TCTL2 = 0x10; while(1) { Tcount = TCNT; Tcount = Tcount + 500; TC2 = Tcount; while (!(TFLG1 & TFLG1_C2F_MASK)); } }