while(!(TFLG1 & 0x40))
and see what the contents of TFLG is the first time you hit this. (BTW - It is good practice to clear pending interrupt flags during an init routine - you had this but have now commented it out)// TCTL1/TCTL2 OM/OL bit defines#define COMPOFF 0#define COMPTOGG 1#define COMPCLEAR 2#define COMPSET 3// Somewhere you enable timer and configure TIOS register once// // timer channels 6-3 are output compares// TIOS |= (1<<6) | (1<<5) | (1<<4) | (1<<3);//void ForceInitialState(void){ // initial OC levels TCTL12 = (COMPSET << 2*6) | (COMPCLR << 2*5) | (COMPSET << 2*4) | (COMPCLR << 2*3); // force initial OC levels CFORC = (1<<6) | (1<<5) | (1<<4) | (1<<3);}void StartWaveform(void){short usTCNT; usTCNT = TCNT; TC3 = usTCNT + 100; TC4 = usTCNT + 105; TC5 = usTCNT + 700; TC6 = usTCNT + 1100; // clear flags TFLG1 = (1<<6) | (1<<5) | (1<<4) | (1<<3); // switch to target OC levels TCTL12 = (COMPCLR << 2*6) | (COMPSET << 2*5) | (COMPCLR << 2*4) | (COMPSET << 2*3); // Since you aren't using interrupts, here you may wait for longest // OC6 compare while( !(TFLG1 & (1<<6)) );}
// TCTL1/TCTL2 OM/OL bit defines#define COMPOFF 0#define COMPTOGG 1#define COMPCLR 2#define COMPSET 3#define MARKPIN 3 // PT3 marks the setting bits in TIOS #define TESTPIN 2 // test OC2void main(void){ TSCR1 |= 0x80; DDRT |= (1<<MARKPIN); for(;;) { int i; TFLG1 = (1<<TESTPIN); // clear flag PTT |= (1<<MARKPIN); TIOS |= (1<<TESTPIN); // change TCx config from IC to OC PTT &= ~(1<<MARKPIN); TFLG1 = (1<<TESTPIN); // clear flag //TCTL setup TCTL12 = (COMPSET << 2*TESTPIN); TFLG1 = (1<<TESTPIN); // clear flag once more *(&TC0 + TESTPIN) = TCNT + 3000; TFLG1 = (1<<TESTPIN); // and once more for(i=0; i<5000; i++); // delay TIOS = 0; // change all TCx config to IC }}
while(!(TFLG1 & 0x40)) { if (TFLG1 & 0x08) Timer3++; if (TFLG1 & 0x10) Timer4++; if (TFLG1 & 0x20) Timer5++; if (TFLG1 & 0x40) Timer6++; }