[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] string decleration
From: |
Rawji, Marc |
Subject: |
[avr-gcc-list] string decleration |
Date: |
Wed, 16 Feb 2005 08:50:15 -0400 |
User-agent: |
Mozilla Thunderbird 0.7.3 (X11/20040803) |
Hello Everyone,
I am having a problem similar to Andre - Bol
(ref:http://www.avr1.org/pipermail/avr-gcc-list/2004-September/007468.html).
In short, I am trying to generate a string and then output it to the uart.
(code snippet)
char str[] = "test";
PORTA = 't'; //properly displays the ascii code for 't'
PORTB = str[0];
(end code snippet)
from what I understand, 'str' should be allocated into SRAM, which is
fine and it should be an array where str[0] = 't', str[1] = 'e', etc...
Well, PORT A and PORTB are different. 'str[0]' always returns 0xFF on
the LEDS.
I have tried different variants, such as:
1) char str[10]; strcpy(&str[0], "test"); //no luck
2) char str[10]; strcpy(str, "test"); //no luck
3) char *str; str = malloc(10); strcpy(str,"test"); // no luck
4) char str[10]; str[0] = 't'; str[1] = 'e'; str[2] = 's'; etc...; //
this one works! and outputs to the uart porperly
I thought I was losing it, so i tried compiling a similar snippet for
i686 using gcc and it works fine.
And here is the really odd part:
using simulavr/avr-gdb/ddd, everything seems fine!
I am running avr-gcc 3.4.3 under linux. Any help would be greatly
appreciated!
The uC is AT90S8515 on a STK500.
Thanks
Marc
- [avr-gcc-list] string decleration,
Rawji, Marc <=