avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] Problems with char */arrays


From: Taj Morton
Subject: [avr-libc-dev] Problems with char */arrays
Date: Sat, 8 Dec 2007 18:35:24 -0800

Hello,
I hope this is the right list...

I was recently trying to get printf() to work with a Hitachi 44780 LCD
screen on an ATmega128. I wrote a driver and a lcd_putchar() function
to write individual chars to the screen. It worked fine when I called
it, but I wasn't able to make printf()/fprintf()/fputs() to write to
the screen. I have tried both gcc-4.2.2 and gcc-4.1.2 along with both
avr-libc-1.4.7 and avr-libc-1.5.1.

I experimented further and found that there seemed to be some sort of
problem with arrays of char in gcc. The following code worked fine on
my computer:
char * hello = "Hello, World";
while (*hello!='\0') {
   putchar(*hello++);
}

but would print garbage to the LCD screen.

The following would also print garbage:
FILE lcd_stream = FDEV_SETUP_STREAM(lcd_putchar, NULL, _FDEV_SETUP_WRITE);
fputs("Hello, World!", &lcd_stream); // (this just prints garbage to the screen

I had done all of this compilation on Linux. Recently, I tried exactly
the same code with the gcc/avr-libc from WinAVR 20070525 and it worked
exactly as expected (it printed the chars, not garbage). The GCC
shipped in WinAVR is 4.1.2 (w/ patches).

Any ideas what might cause this?
Thanks!
- Taj


-- 
Taj
http://www.wildgardenseed.com/Taj/blog

Need a GMail invite? Email me.
Peace cannot be kept by force; it
can only be achieved by understanding.
                -- A. Einstein




reply via email to

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