Sujith,
Regarding question (3.) I think you might only be trying to stop the output compare, and normally you would not need to stop TCNT as it is a freerunning system timer. Of course you can still stop it for whatever reason, but just stopping with TEN leaves it on the time that triggered the OC interrupt.
- To clear the interrupt flag, write '1' to the appropriate bit in TFLG1:
TFLG1 = (1<<4); // clears OC interrupt flg for TC4
- To stop future interrupt events on TC4, clear the interrupt enable bit in TIE:
TIE &= ~(1<<4); // disables interrupts on TC4
- To re-enable interrupt events on TC4, clear the interrupt flag first because there is likely an event pending that should be ignored:
TC4 = TCNT + 0x100 // set a new time for event 256 ticks from now
TFLG1 = (1<<4); // clear previously ignored flag, no matter if was already 0
TIE = (1<<4); // enable interrupt
Message Edited by imajeff on 2006-09-21 11:47 AM