Software avoids interrupt overhead

Hans-Herbert Kirste, WAGO Kontakttechnik GmbH, Minden, Germany -- EDN, 3/2/2000

You can service peripheral ICs connected to a µC by polling or via interrupts. The polling method can be time-consuming, so interrupt handling is often preferable because the µC has to take care of the peripheral only on request. However, each separate interrupt causes the µC to stop normal program execution, save its current state on the system stack, and vector to the interrupt's processing function. The first instructions in the interrupt function normally push some or all registers used onto the stack.

Peripherals, such as the 16550 UART, that have more than one interrupt source, may require that the µC process more than one request at a time. Fortunately, you can write software that allows the µC to process more than one request in one interrupt cycle. Thus, the interrupt overhead occurs only once. The result is improved system performance.

Listing 1 is an example of standard interrupt-handling software. Standard practice involves vectoring, pushing, and popping registers for each interrupt request. A more sophisticated function in Listing 2 tries to handle as many interrupt requests as the peripheral requires. This function processes multiple reads to the identification register, and the process repeats until the µC has serviced all sources. (DI #2489)




ADVERTISEMENT

ADVERTISEMENT

Feedback Loop


Post a CommentPost a Comment

There are no comments posted for this article.

Related Content

 

By This Author

There are no additional articles written by this author.


ADVERTISEMENT

Knowledge Center



Technology Quick Links

EDN Marketplace


©1997-2008 Reed Business Information, a division of Reed Elsevier Inc. All rights reserved.
Use of this Web site is subject to its Terms of Use | Privacy Policy

Please visit these other Reed Business sites