Is port interrupt flag cleared when IRQ is executed?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now, this is possibly a really silly question.

I'm using the ATxmega128A1. Port C pin 5 is an input, used to trig port interrupt 0 (rising edge sensing). No problem there "“ everything works.

While porting the code from ATmega1281, I didn't add PORTC_INTFLAGS=1 to clear the interrupt flag, assuming that the flag would be cleared by hardware. Yes, I know. Never assume. But the flag appears to be cleared by hardware anyway.

The thing that confuses me is this: As far as I can tell, none of the relevant documents from Atmel mentions that the port interrupt flags are cleared by hardware. I've looked through the XMEGA A manual (which just claims that "Writing a one to this flag's bit location will clear the flag." and "For most interrupts, the interrupt flag is automatically cleared when executing the interrupt vector."), the XMEGA A1 datasheet (which says even less), application note AVR1313 (which says just about nothing), and application note AVR1305 (which redirects the reader to the datasheet...).

My question: Is the xmega supposed to clear port interrupt flags by hardware, and have Atmel just forgotten to spell it out for the dummies, or is it just sheer luck that my code works?

Br, E

You're absolutely right. This member is stupid. Please help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The XA manual has this:

13.14.13     INTFLAGS - Interrupt Flag Register 

Bit              7           6          5           4           3           2           1           0 

                                  +0x0C            -           -          -           -           -           -         INT1IF     INT0IF     INTFLAGS 

                                   Read/Write      R          R           R           R           R           R          R/W        R/W 

                                   Initial Value   0           0          0           0           0           0           0           0 

(cut paste doesn't work too well!) but the key thing here is the documented "Initial Value" for the register is all 0 0 0 0 0... You can read that as "cleared as power on default" can't you?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

You can read that as "cleared as power on default" can't you?

But the question appears to be, not related to initial value: "In classic AVR8, the datasheet spells out the clearing (or not) action for interrupt flags. I cannot find similar information for Xmega, in particular ."

It appears that for the Xmega, the "normal" behaviour is described in the interrupt handling overview per the quote below. That implies that only the exceptions will have a note at the particular flag description.

Quote:
All interrupts have an interrupt flag associated with it. When the interrupt condition is present, the interrupt flag will be set, even if the corresponding interrupt is not enabled. For most interrupts, the interrupt flag is automatically cleared when executing the interrupt vector. Writing a logical one to the interrupt flag will also clear the flag. Some interrupt flags are not cleared when executing the interrupt vector, and some are cleared automatically when an associated register is accessed (read or written). This is described for each individual interrupt flag.

So, what are the exceptions? DREIF keeps firing--but that is a bit different animal. Low level? That is another that keeps firing on AVR8.

[pure speculation] To the OP: I'd say your guess "assuming that the flag would be cleared by hardware" is correct based on the omnibus statement in Interrupts overview.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are right, Theusch. I meant "cleared by hardware when executing the interrupt vector".

Yeah, it would make sense (kind of), if only the exceptions were spelled out in detail. But other interesting peripherals (Timer/Counter, USART, ADC, SPI) have the interrupt flag details spelled out, even if they are not exceptions. So my best guess is that the author just forgot to write that part.

You're absolutely right. This member is stupid. Please help.