Article ID: 000083437 Content Type: Troubleshooting Last Reviewed: 09/11/2012

When using a JTAG UART or UART for stdout, why is the printf output truncated when it is immediately before the program is terminated?

Environment

  • Nios® II Processor
  • BUILT IN - ARTICLE INTRO SECOND COMPONENT
    Description The JTAG UART and UART drivers' output buffer may not be completely transmitted when the printf statement is immediately before the program is terminated. So, if the last statement of your program is a printf, you may not observe the entire message from the printf statement. To ensure that the entire message is printed, put a usleep() statement after the printf() statement to allow time for the JTAG UART or UART driver output buffer to be completely transmitted to the JTAG UART or UART hardware. Adding "usleep(200000);" (wait for 200000 us) is usually sufficient.

    Note that this behavior only occurs when the JTAG UART or UART is interrupt driven, which is the default. When using the polled versions of the drivers, the driver waits for the JTAG UART or UART hardware before sending and receiving characters. The entire printf message will be printed before the next processor instruction is executed. Refer to the Quartus II Handbook, Volume 5: Altera Embedded Peripherals for information on the fast (interrupt driven) versus small (polled) drivers for the JTAG UART and UART peripherals.

    Related Products

    This article applies to 1 products

    Intel® Programmable Devices