Keil Logo

µVISION DEBUGGER: Debug printf via ITM fails without Microlib


Information in this knowledgebase article applies to:

  • ARM-MDK v5.x
  • ARMCC compiler v5.x
  • ARMCLANG compiler v6.x

SYMPTOM

I have configured and enabled SWO trace in µVision debugger settings properly and tried redirecting debug printf output via ITM stimulus port 0. 

But the following code snippet only works, when "Use MicroLIB" is enabled in Options for Target - Target - Code Generation. With normal ARM C standard library, i.e. without enabling "Use MicroLIB", I don't have any string printed out in Debug (printf) Viewer in µVision debug session. 

How to make my printf code snippet work without using Microlib?

printf("Core clock is %dMHz", SystemCoreClock/1000000);

CAUSE

In ARM C standard library, the stdout stream is buffered. The printf output won't be displayed until it reaches a newline (or a line break), or until the buffer is full. 

ARM Microlib, however, doesn't buffer the stdout stream. 

That's the reason why the printf code snippet works fine with Microlib, but not with ARM C standard library. 

RESOLUTION

Adding a line break '\n' character into code snippet above can resolve this issue, when ARM C standard library is used.

printf("Core clock is %dMHz\n", SystemCoreClock/1000000);

MORE INFORMATION

Last Reviewed: Friday, January 5, 2018


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.