Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
689 Views

printf bug?

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 I
44 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.
Reply