[Top][All Lists]

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

[avr-gcc-list] stdio is only partially functional

From: Sander Pool
Subject: [avr-gcc-list] stdio is only partially functional
Date: Mon, 17 Mar 2003 00:23:34 -0800


I am finally enabling stdio on my mega128 project. I'm seeing some odd
behavior I hope you can help with. Somehow I can output individual
characters just fine but strings get clobbered.

When I do a sequence of calls like this:

        fprintf(stdout, "fprintf\n");
        fprintf_P(stdout, "fprintf_P\n");
        fputs("fputs\n", stdout);
        fputs_P("fputs_P\n", stdout);
        fputc('X', stdout);

I get:

fS??.?d??'TA0"Q "P?a?"T?.?{??S.?lS??.?h??Y'?'?'/'????.''?'$/
_"o"?"Y" '^f "P?a?"T?.?{??S.?lS??.?h??Y'?'?'/'????.''?'$/"?"O"_"o
" '^XY

on my terminal. X, Y and \n are transmitted fine but the string prints
aren't even the right number of characters. I'm probably doing something
silly, I hope you can help me identify it. I init my streams like this:

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

void RL_USART_Init(uint16_t ubrr)
        UBRR1H = ubrr >> 8;
        UBRR1L = ubrr & 0xff;
        UCSR1B = _BV(TXEN);
        stdout = fdevopen(RL_tryout, NULL, 0);
        stderr = stdout;



PS I know that only the _P routines should work in this case but I figured I
may as well try both.

reply via email to

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