avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] stdio problem fixed


From: Sander Pool
Subject: [avr-gcc-list] stdio problem fixed
Date: Mon, 17 Mar 2003 21:18:54 -0800

Thanks Volkmar for sending the code sample that worked. The small but
apparently critical difference was that I returned a non-null value from my
character write routine and you send back a '0'.

So:

int RL_tryout(char c)
{
        if (c == '\n') {
                // first output a carriage return
                RL_tryout('\r');
        }
        loop_until_bit_is_set(UCSR1A, UDRE);
        UDR1 = c;

        return 0;
}

works but

int RL_tryout(char c)
{
        if (c == '\n') {
                // first output a carriage return
                RL_tryout('\r');
        }
        loop_until_bit_is_set(UCSR1A, UDRE);
        UDR1 = c;

        return c;
}

Does not. There were probably some other things wrong as well that caused
the garbage characters to be sent. Most likely the PSTR thingy.

So in any case, when you return a non-null value printf still works but puts
does not, it only prints the first character.

So the example in the docs is right and I should have copied it to the
letter :-) Still, is this expected behavior?

        Sander



reply via email to

[Prev in Thread] Current Thread [Next in Thread]