FAQ:Interrupts

From GNU 68HC11/HC12
Revision as of 17:02, 18 February 2006 by Stephane.Carrez (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

This FAQ section gives some tips about interrupts on 68HC11 and 68HC12.

How can I setup an interrupt table for a ROM?

A special section exists for the definition of the interrupt vector table of the 68HC11 or 68HC12. The vectors must be in a section named .vectors.

In assembly, use:

.sect .vectors

With gcc, use:

__attribute__ ((section (".vectors")))

How can I define an interrupt table?

This seems to work for me (borrowed from other users)

void __attribute__((interrupt)) isr_empty(void){
       inchar = SC0SR1; //needed to clear RDRF flag
       inchar = SC0DRL; //read incoming character
       sci_putch(inchar);
}
void __attribute__((interrupt)) isr_empty(void){/* do nothing */}
extern void _start(void);/* entry point in crt0.s */
void __attribute__ (( section (".vectors";) )) (* const interrupt_vectors[])(void) = {
       isr_empty, /* $ffc0: reserved */
       isr_empty, /* $ffc2: reserved */
       isr_empty, /* $ffc4: reserved */
       isr_empty, /* $ffc6: reserved */
       isr_empty, /* $ffc8: reserved */
       isr_empty, /* $ffca: reserved */
       isr_empty, /* $ffcc: reserved */
       isr_empty, /* $ffce: reserved */
       isr_empty, /* $ffd0: reserved */
       isr_empty, /* $ffd2: reserved */
       isr_empty, /* $ffd4: reserved */
       sci_int, /* $ffd6: SCI serial system */
       isr_empty, /* $ffd8: SPI serial transfer complete (SPIE) */
       isr_empty, /* $ffda: Pulse accumulator input edge (PAII) */
       isr_empty, /* $ffdc: Pulse accumulator overflow (PAOVI) */
       isr_empty, /* $ffde: Timer overflow (TOI) */
       isr_empty, /* $ffe0: Timer channel 7 */
       isr_empty, /* $ffe2: Timer channel 6 */
       isr_empty, /* $ffe4: Timer channel 5 */
       isr_empty, /* $ffe6: Timer channel 4 */
       isr_empty, /* $ffe8: Timer channel 3 */
       isr_empty, /* $ffea: Timer channel 2 */
       isr_empty, /* $ffec: Timer channel 1 */
       isr_empty, /* $ffee: Timer channel 0 */
       isr_empty, /* $fff0: Real-time interrupt (RTII) */
       isr_empty, /* $fff2: -IRQ (external pin) */
       isr_empty, /* $fff4: -XIRQ pin */
       isr_empty, /* $fff6: Software interrupt */
       _start, /* $fff8: Illegal opcode trap */
       _start, /* $fffa: COP failure (NOCOP) */
       _start, /* $fffc: Clock monitor fail (CME) */
       _start /* $fffe: -RESET (hardware reset) */
};
Personal tools