beautypg.com

Zilog Z16F2810 User Manual

Page 63

background image

UM018809-0611

Interrupts

ZNEO

®

CPU Core

User Manual

47

Polling is performed in a frequently-executed section of code, such as the main loop of an
interactive program. For processor-intensive applications, there can be a trade-off between
the responsiveness of polled interrupts and the overhead of frequent polling.

To poll the bits of interest in an Interrupt Request register, use the Test Under Mask (TM)
or similar bit test instruction. If the bit is 1, perform a software call or jump to the interrupt
service routine. The interrupt service routine must clear the Interrupt Request Bit (by writ-
ing 1 to the bit) in the Interrupt Request Register and then return or branch back to the
main program.

Example.

The following example outlines the sequence of a polling routine:

INCLUDE "

device

.INC" ; Include device-specific label

; definitions

LD R0, #00100000B ; Load mask for bit 5

TM.B IRQ1, R0 ; Test for 1 in IRQ1 Bit 5

JP Z, NEXT ; If no IRQ, go to NEXT

CALL SERVICE ; If IRQ, call the interrupt

; service routine.

NEXT:

;[Insert additional program code here.]

SERVICE: ; Process interrupt request

;Service routine code here.

LD.B IRQ1, R0 ; Write a 1 to clear IRQ1 bit 5

RET ; Return to address after CALL

Do not use IRET when returning from a polled interrupt service routine.

For information about the Interrupt Request registers, refer to the ZNEO Product Specifica-
tion that is specific to your device.

Caution:

Note:

This manual is related to the following products: