beautypg.com

Zilog EZ80F916 User Manual

Page 156

background image

UM014423-0607

Using the ANSI C-Compiler

ZiLOG Developer Studio II

eZ80Acclaim!

®

User Manual

136

a value. Because an interrupt handler is not called from another function but vectored to
by the hardware, you cannot pass parameters to it. Interrupt routines can, however, access
global variables or static variables. The compiler issues a warning if it detects an interrupt
routine with arguments.

The compiler stores the machine state at the beginning of these functions and restores the
machine state at the end of these functions. The

interrupt

and

nested_interrupt

pragma

s are handled differently in the compiler. You should use

#pragma

interrupt

for all interrupt handlers if your application does not make use of nested interrupts; other-
wise, use

#pragma

nested_interrupt

for all interrupt handlers. It is important to use

either

interrupt

or

nested_interrupt

consistently throughout your application.

Specifically, the (non-nested)

interrupt

function executes an

EXX

instruction that pre-

serves all the current registers upon entry to the function and an

EXX

instruction to restore

the registers at the function exit. On the other hand,

nested_interrupt

does not use the

alternate registers and instead pushes registers on the stack based on their use in the func-
tion. In either case, the compiler uses the reti instruction to return from these functions.
For example:

void interrupt isr_timer0(void) /* For non-nested interrupt use model */
{}

or

void nested_interrupt isr_timer0(void) /* For nested interrupt use model */
{}

or

#pragma interrupt /* For non-nested interrupt use model */
void isr_timer0(void)
{}

or

#pragma nested_interrupt /* For nested interrupt use model */
void isr_timer0(void)
{}

If you want the compiler to use the

retn

instruction to return from the interrupt, use

#pragma nmi_interrupt

. For example:

#pragma nmi_interrupt /* ISR for non maskable interrupt */
void isr_nmi(void)
{}

Interrupt Vector Setup
The compiler provides the

_set_vector

function for interrupt vector setup. This func-

tion can be used to specify the address of an interrupt handler for an interrupt vector. The

_set_vector

function works by dynamically reading the base of the vector table and

placing the address of the interrupt handler in it.

This manual is related to the following products: