ARM Technical Support Knowledge Articles

INCLUDING TEST CODE IN APPLICATIONS

Applies to: General Topics

Answer


Information in this article applies to:


QUESTION

While testing my embedded application, I need to output debugging information. Is it possible to write code that is executed only in debug mode?

ANSWER

Yes. There are several ways you can accomplish this.

Including Calls to printf in Your Application

You may use #define and #if pre-processor statements to include parts of your code in a debug version of your software. For example, you can write:

void main (void)  {
  init_serial ();         // initilize serial interface
#ifdef DEBUG
  printf ("This is a Debug Version\n");
  test_function ();
#endif
  standard_function ();
  while (1);
}

When you use uVision2 you may:

Using the Debugger to Output Debug Information

You may set breakpoints in the debugger that output information including the values of program variables. For example, in uVision2, you may enter the following in the command window to output the value of the variable j in the debugger's command window.

bs \blinky\15 , 1, "printf(\"j = %u\\n\", (unsigned) j)"

This command sets a breakpoint on line 15 of the module named blinky. Each time the line is executed, the value of j is output to the command window.

Article last edited on: 2001-10-18 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