S12Z Interrupt catcher for unexpected interrupts

Document created by Radek Sestak Employee on Apr 4, 2016Last modified by Radek Sestak Employee on Jan 16, 2020
Version 5Show Document
  • View in full screen mode

Interrupt catcher example code catches all unexpected interrupts.

It can be used for debugging or directly in the application software.

The Machine Exception routine is used here as example of expected interrupt.


A few notes:

1. For each expected interrupt you must remove a code line for given interrupt

    from the part of the code "A Set of unimplemented interrupts" and

    create your own service routine as it is, for example, made

    for interrupt 5 void Machine_Exception_ISR(void)


2. All interrupt vectors have 32bit size, however, addresses have only 24bit,

    therefore the most significant byte in interrupt vector is not used.

    Definitions with the keyword "interrupt XX" where XX represents vector

    order in the interrupt vector is used to define interrupt service function.


3. Interrupt number 0 is assigned to POR reset vector,

                     1 is assigned to Unimplemented page1 op-code trap vector

                     2 is assigned to Unimplemented page2 op-code trap vector

                     3  ...

                     4  ...

    Interrupt number = (0x1FC-Vector Address)/4. See Table 1-11. Interrupt

    Vector Locations at RM(page 62-65).

    For Example: Interrupt number of SCI0 = (0x1FC-0x19C)/4 = 0x18 = 24.

    So you can use either form

               interrupt VectorNumber_Vsci0 void SCI0_isr(void)


               interrupt 24 void SCI0_isr(void)


               interrupt ((0x1FC-0x19C)/4) void SCI0_isr(void)


    Note: VectorNumber_Vsci0 is defined in mc9s12zvl32.h      

3 people found this helpful