Author Topic: GIFR - Interrupt flag  (Read 1482 times)

0 Members and 1 Guest are viewing this topic.

Offline TrickyNekroTopic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
GIFR - Interrupt flag
« on: January 01, 2009, 07:52:29 PM »
Hello again,

I'm using the ATMEGA32 for a project of mine but I have a simple question...
If you use a button, you are going to have debounce problems cause it's the real world and it's not perfect...
Now... if the button is connected to an interrupt and you don't do anything to debounce it, it's
more than probable that the interrupt code will execute twice or more, something that I don't want at all...

So while on the interrupt routine I want to clear GIFR to prevent multi-interrupts... (and some debounce wait time)

My problem is that (I read the manual), I don't understand how to clear the GIFR...
It says,

 that the flag is cleared by the end of the execution of the interrupt code (unless another interrupt occurs, of course)
And that you can manually clear the flag by writing logic 1 to the flag...

But if no interrupt occurs and as said the initial Value of the flag is logic 0...

So... what I do here... I write 0 to the INTFX or 1 to clear it manually....
What I think is that I write 1 but it's not.... logical....


Thanks in advance, Lefteris
Greece
For whom the interrupts toll...

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: GIFR - Interrupt flag
« Reply #1 on: January 01, 2009, 09:23:31 PM »
Some registers are backwards like that, where you actually have to write a '1' to clear is and not a '0'
 ;)




Offline TrickyNekroTopic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
Re: GIFR - Interrupt flag
« Reply #2 on: January 01, 2009, 09:34:49 PM »
That's what I wanted to hear!!! Thanks man! ;)
For whom the interrupts toll...

 


Get Your Ad Here

data_list