exception.S interrupt handler

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

Can anybody explain the motivation for the code in exception.S for INT0..INT3 where the mode bits are checked and if they are greater than or equal to B`110, that is we are in exception mode, we move the saved PC and SR up on the stack, restore R12, move SP up and do an rete, effectively ignoring the interrupt?

If we autovectored to the code for an interrupt, it seems that the mode bits should be set for that interrupt level. Is this trying to handle getting an enabled interrupt in the middle of handling an exception? The method of handling this situation is to ignore the interrupt, without clearing the interrupt condition, finishing the exception and then coming back to it, by vectoring to the interrupt handler again?

This one has me chasing my tail; can anyone clear up my confusion?

Edit: The version of `exception.S' from NewLib does not suffer from this crock.

We never have time to do it right,
but we always have time to do it over

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

I'd still like to know why the code for interrupts 0 through 3 is written the way it is in several versions of exception.S I've included the code in question

_int0:
  // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the
  // CPU upon interrupt entry.
#if 1 // B1832: interrupt stack changed to exception stack if exception is detected.
  mfsr    r12, AVR32_SR
  bfextu  r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE
  cp.w    r12, 0b110
  brlo    _int0_normal
  lddsp   r12, sp[0 * 4]
  stdsp   sp[6 * 4], r12
  lddsp   r12, sp[1 * 4]
  stdsp   sp[7 * 4], r12
  lddsp   r12, sp[3 * 4]
  sub     sp, -6 * 4
  rete
_int0_normal:
#endif
  mov     r12, 0  // Pass the int_lev parameter to the _get_interrupt_handler function.
  call    _get_interrupt_handler
  cp.w    r12, 0  // Get the pointer to the interrupt handler returned by the function.
  movne   pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.
  rete            // If this was a spurious interrupt (R12 == NULL), return from event handler.

Specifically why are we checking for mode 6 in the int0 handling?

Also what does B1832 in the comment refer to?

We never have time to do it right,
but we always have time to do it over

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

I'd really like to have any opinion at all on why the code fragment above is written the way it is.

Anybody wanna take a crack at it?

We never have time to do it right,
but we always have time to do it over

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

I've sent a request off to Atmel. I'll report back if I get any kind of answer.

We never have time to do it right,
but we always have time to do it over

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

interesting... I will wait for the answer

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

Papabravo
Did you ever get an answer to this??
I have a need to get minimum interupt latency and this is a big issue!!
Thanks
dave