ARM Technical Support Knowledge Articles

CALLING PRINTF FROM AN INTERRUPT

Applies to: General Topics

Answer


Information in this article applies to:


QUESTION

Are there any reasons why I shouldn't call the printf function from within an interrupt?

ANSWER

There are numerous good reasons to avoid calling printf from an interrupt routine.

Interrupt routines are typically used to respond to events that occur quickly. For this reason, it is usually important that interrupt service routines run fast. The printf function is not a fast routine. Especially if you consider that the output from printf may output to the slow serial port. At 1200 baud, a 100 character string takes almost 1 second to send. The printf function will therefore take more than that to execute. In this case, your interrupt service routine will take around 1 second to execute. If that interrupt happens faster than once per second, you will lose interrupts.

Article last edited on: 2000-05-24 00:00:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential