TIFR1 not writable on ATMega2560?

void setup()
{
  Serial.begin(9600);
  Serial.write(TIFR1);
  TIFR1=12;
  Serial.write(TIFR1);
}
void loop()
{
}

As read from the serial port, TIFR1 is 0 both before and after writing it to 12. Why?

TIFR is an interrupt flag register.
1 is set when the interrupt condition is met.
Writing 1 there means clearing to 0.
Please refer to the datasheet.

So there're no ways to write it to logical one manually?

Yes it is.

Tell us why you want to do this.

Why are you trying to set Bit 3 which is reserved and will always read as 0?

Note: I don't think there is any way to cause a compare match interrupt. You should be able to call the ISR if you want to pretend a match happened.

Be careful if you do that. What happens if the interrupt occurs during the "manual" function call? Is the ISR reentrant-safe?

If not surround the manual call with noInterrupts() / interrupts().

why the double post?

you already had an answer here

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.