0

I have a problem with set-up interruption flag in AVR AT90S2313. Normally interruption is setting-up through hardware counter. I want to setting this flag in programming way when I want (at the specific moment). I'm writing all code in C:

SEI();                  //enable globall interupt
TIMSK | = (1<<TOIE1);    //enable interrupt from timer 1
TIFR | = (1<<TOV1);      //enable interruption (setting bit) - IT DOESN"T WORKS!

So, in the last line it should be programming interruption but nothing is happening and I don't know why. Any idea? Thanks in advance.

caro
  • 381
  • 3
  • 5
  • 20

1 Answers1

1

TIFR registers are special in that writing a 1 to a bit sets it to 0.

Edit in response to a comment:

You shouldn't be doing anything with the register as far as I can tell from what little information you have supplied. That is, don't try to use the interrupt mechanism to run the handler. At the point in your code where you want to trigger the interrupt, just call the handler yourself. You may also want to be adjusting the enable bits or clearing flags at the same time -- I don't know what you are trying to do.

If you want the handler to run as if it were acting in response to an interrupt, then you will want to disabled interrupts first. The usual way to do this is

void function_to_trigger_handler()
{
     uint8_t sreg = SREG;
     cli();

     my_interrupt_handler();

     SREG = sreg;
}
UncleO
  • 8,299
  • 21
  • 29
  • Thanks but I think I don't understand. Could you be more specific? What should I do whit this register? – caro Jan 20 '13 at 13:16