Topic : Spurious IRQ handler

Forum : ST7/STM8

Original Post
Post Information Post
June 10, 2009 - 7:00pm
Raisonance Support Team

Hi all,

During development is is sometimes tedious to work with IRQs, as they are asynchronous and difficult to track.

We developped a small utility that will make it easy to capture all the IRQs that occur on a given application. You just have to include the file in your project (STM8 only, ST7 is not supported) and to place a breakpoint on the panic() function.

Remove the redirection for the IRQs that you handle in your application (if you don't, you will have a linker error anyway ;)

You can write a little code in the panic() function, such as lighting an error LED.

// spurious_irq.c
// This file defines the panic() function as a common handler for all IRQs
// Setting a single breakpoint on the panic() function will catch any IRQ.

// Function called in case of spurious IRQ or TRAP
void panic(void) trap
{
    // Place a breakpoint here. ALL IRQs will be catched.
}

// Define the ISR type, which is a pointer to an interrupt function
typedef void far* ISR;       // far* is necessary for 3-bytes address

// At absolute address (0x8008 + interruptNumber * 4) place a 0x82 byte,
// then the 3-bytes address of the handler
at 0x8008 code unsigned char vect0_head = 0x82;
at 0x8009 code ISR vect0 = panic;
at 0x800C code unsigned char vect1_head = 0x82;
at 0x800D code ISR vect1 = panic;
at 0x8010 code unsigned char vect2_head = 0x82;
at 0x8011 code ISR vect2 = panic;
at 0x8014 code unsigned char vect3_head = 0x82;
at 0x8015 code ISR vect3 = panic;
at 0x8018 code unsigned char vect4_head = 0x82;
at 0x8019 code ISR vect4 = panic;
at 0x801C code unsigned char vect5_head = 0x82;
at 0x801D code ISR vect5 = panic;
at 0x8020 code unsigned char vect6_head = 0x82;
at 0x8021 code ISR vect6 = panic;
at 0x8024 code unsigned char vect7_head = 0x82;
at 0x8025 code ISR vect7 = panic;
at 0x8028 code unsigned char vect8_head = 0x82;
at 0x8029 code ISR vect8 = panic;
at 0x802C code unsigned char vect9_head = 0x82;
at 0x802D code ISR vect9 = panic;
at 0x8030 code unsigned char vect10_head = 0x82;
at 0x8031 code ISR vect10 = panic;
at 0x8034 code unsigned char vect11_head = 0x82;
at 0x8035 code ISR vect11 = panic;
at 0x8038 code unsigned char vect12_head = 0x82;
at 0x8039 code ISR vect12 = panic;
at 0x803C code unsigned char vect13_head = 0x82;
at 0x803D code ISR vect13 = panic;
at 0x8040 code unsigned char vect14_head = 0x82;
at 0x8041 code ISR vect14 = panic;
at 0x8044 code unsigned char vect15_head = 0x82;
at 0x8045 code ISR vect15 = panic;
at 0x8048 code unsigned char vect16_head = 0x82;
at 0x8049 code ISR vect16 = panic;
at 0x804C code unsigned char vect17_head = 0x82;
at 0x804D code ISR vect17 = panic;
at 0x8050 code unsigned char vect18_head = 0x82;
at 0x8051 code ISR vect18 = panic;
at 0x8054 code unsigned char vect19_head = 0x82;
at 0x8055 code ISR vect19 = panic;
at 0x8058 code unsigned char vect20_head = 0x82;
at 0x8059 code ISR vect20 = panic;
at 0x805C code unsigned char vect21_head = 0x82;
at 0x805D code ISR vect21 = panic;
at 0x8060 code unsigned char vect22_head = 0x82;
at 0x8061 code ISR vect22 = panic;
at 0x8064 code unsigned char vect23_head = 0x82;
at 0x8065 code ISR vect23 = panic;
at 0x8068 code unsigned char vect24_head = 0x82;
at 0x8069 code ISR vect24 = panic;
at 0x806C code unsigned char vect25_head = 0x82;
at 0x806D code ISR vect25 = panic;
at 0x8070 code unsigned char vect26_head = 0x82;
at 0x8071 code ISR vect26 = panic;
at 0x8074 code unsigned char vect27_head = 0x82;
at 0x8075 code ISR vect27 = panic;
at 0x8078 code unsigned char vect28_head = 0x82;
at 0x8079 code ISR vect28 = panic;
at 0x807C code unsigned char vect29_head = 0x82;
at 0x807D code ISR vect29 = panic;

I hope this helps, feel free to share your comments.
Bruno