AnsweredAssumed Answered

Spurious interrupt with __declspec(interrupt)

Question asked by Kevin Bube on Apr 24, 2017
Latest reply on Apr 27, 2017 by TomE

Hi all,


I am using a MCF5474 with CodeWarrior 6.4. I recently introduced an exception handler to count SLT0 overflows that runs on Level 7. It is registered with


static void setup_time_counter()
MCF_SLT_SLTCNT0 = 0xFFFFFFFF; /* count from 2^32 */
MCF_SLT_SCR0 = MCF_SLT_SCR_IEN /* enable interrupt */
| MCF_SLT_SCR_TEN /* enable timer */
| MCF_SLT_SCR_RUN; /* run continuously */
MCF_INTC_ICR54 = 0x39; /* priority 7.1 */


The interrupt handler looks like this


static unsigned long counter_wraps = 0;


__declspec(interrupt) void slice_time_counter()
/* just count the overflows of the slice timer */
MCF_SLT_SSR0 = MCF_SLT_SSR_ST; /* reenable IRQ */


And in the vector table


.extern _slice_time_counter


vector76: .long _slice_time_counter


I now randomly get spurious interrupts. They happen about 2-8 times a day.


If I change the __declspec(interrupt) line to #pragma interrupt on .... #pragma interrupt off the problem goes away. The only difference I see in the generated assembly code is that the first line in the handler is "move.w #0x2700, sr" for __declspec. This line is missing with #pragma. No doubt, writing to the status register should not be necessary as the IRQ level is 7 anyway, so the line is redundant and can go away. But why does it cause spurious interrupts?


Is this a known problem? What is the cause?