[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] string decleration
From: |
Daniel O'Connor |
Subject: |
Re: [avr-gcc-list] string decleration |
Date: |
Thu, 17 Feb 2005 00:20:25 +1030 |
User-agent: |
KMail/1.7.92 |
On Wed, 16 Feb 2005 23:20, Rawji, Marc wrote:
> 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...
I use these for sending stuff out the UART (I'm using the 8515 which only has
one :)
int
uart_putc(char c) {
loop_until_bit_is_set(USR, UDRE);
outp(c, UDR);
return(0);
}
void
uart_putsP(const char *addr) {
char c;
while ((c = PRG_RDB((unsigned short)addr++)))
uart_putc(c);
}
void
uart_puts(const char *addr) {
while (*addr)
uart_putc(*addr++);
}
> Well, PORT A and PORTB are different. 'str[0]' always returns 0xFF on
> the LEDS.
0xff almost certainly means it isn't in SRAM..
I think the problem is because it's static the compiler puts it in PGM space.
Does..
char str[10];
strcpy(str, "test");
work?
--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
pgpEfPXEBgTvs.pgp
Description: PGP signature