#include #ifndef TFLG1_C6F_MASK #define TFLG1_C6F_MASK 0x40 #endif unsigned int Tcount, T1, T2; void main(void) { DDRB = 0xFF; TSCR1 = 0x80; TSCR2 = 0x07; TIOS = TIOS & ~0x40; while(1) { TCTL3 = 0x10; while (!(TFLG1 & TFLG1_C6F_MASK)); TFLG1 = TFLG1 | TFLG1_C6F_MASK; T1 = TC6; TCTL3 = 0x20; while (!(TFLG1 & TFLG1_C6F_MASK)); TFLG1 = TFLG1 | TFLG1_C6F_MASK; T2 = TC6; Tcount = T2 - T1; PORTAB = Tcount; } }