Results 1 to 2 of 2

Thread: printf bug?

  1. #1
    Join Date
    Jan 2012
    Posts
    31
    Rep Power
    1

    Default printf bug?

    Hello.
    I've encountered a strange behaviour of prinf function. The code is a simple "hello world" example:
    Code:
    #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.
    Last edited by CosworthRS; April 7th, 2012 at 03:33 AM.

  2. #2
    Join Date
    Jun 2010
    Location
    Spain
    Posts
    1,265
    Rep Power
    1

    Default Re: printf bug?

    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.

Similar Threads

  1. Problem in printf
    By lasd in forum General Altera Discussion
    Replies: 0
    Last Post: November 24th, 2008, 08:09 AM
  2. printf and %f ????
    By tux.2000 in forum General Software Forum
    Replies: 0
    Last Post: February 12th, 2007, 01:52 AM
  3. Printf failed
    By burdalex in forum General Discussion Forum
    Replies: 5
    Last Post: January 4th, 2006, 12:51 PM
  4. I can't printf
    By sirga in forum General Software Forum
    Replies: 1
    Last Post: November 24th, 2005, 09:07 AM
  5. Redirecting printf?
    By ppk031000 in forum General Software Forum
    Replies: 2
    Last Post: October 26th, 2005, 10:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •