Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

printf bug?

Altera_Forum
Honored Contributor II
881 Views

Hello. 

I've encountered a strange behaviour of prinf function. The code is a simple "hello world" example: 

#include <stdio.h> int main() { printf("Hello 1\n"); printf("HELLO 2\n"); return 0; } 

It works and the result are two lines in console. But once i remove the second printf, it does not show up a line. When I run debug, it seem that processor executes something and does not even reach the main function. The QSys system is Nios(50MHz)+JTAG UART(50MHz)->clock bridge(50 to 143MHz)->SDRAM controller(143MHz), and timing constraints are met. 

Just found out that it works if there is no \n symbol.
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
236 Views

Try with a delay loop just before the return or even with a while(1) after the last printf. 

Functions like printf are non-blocking: the string is sent to the jtag uart buffer, but transmission will take place when the interface is ready, thus it could be delayed. 

Terminating the program before transmission has completed could prevent data from being received by your terminal.
0 Kudos
Reply