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

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

[avr-gcc-list] Wrong pointer during procedure call


From: Markus Wyss
Subject: [avr-gcc-list] Wrong pointer during procedure call
Date: Wed, 2 Jun 2004 21:21:53 +0200

Hi !

First of all, thanks to all who are addicted to AVR and WinAVR ...

I do have the following problem:
First I have defined a const string in the .text section (Flash) as
shown below:

const uint8_t Text[20] __attribute__ ((section (".text"))) = "For ever WinAVR";

Then I wrote a procedure to send a string as shown below:

void RS232_PutString(const char* ch)
{
  uint8_t pos;
  
  pos = 0;
  
  while (ch[pos] != 0)
  {
    RS232_PutChar(ch[pos]);
    pos++;
  }
}

Finaly, I call this procedure as follows:

RS232_PutString(Text1);


The local var 'ch' in the procedure gets the correct pointer, in my case 0x009C 
[FLASH].
So the problem is, that the procedure interprets this pointer as 0x009C [SRAM]. 
As a
result, the wrong bytes are sent to RS232_PutChar.

1.) How do I have to define the parameter ch, that the pointer points to FLASH 
and
not to SRAM?

2.) I thought, when I define a string like: const uint8_t Str[5] = "ABCD"; it 
will be
placed into the .text section (Flash). But it is placed into the .data (SRAM) 
section.
Why?



Thanks for your help!

Markus











reply via email to

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