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

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

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


From: Petrik Gergely
Subject: Re: [avr-gcc-list] Wrong pointer during procedure call
Date: Wed, 2 Jun 2004 21:35:54 +0200 (CEST)

Hello!

You should use pgm_read_byte() or pgm_read_word() macros to
access data stored in program memory. And use macro PROGMEM
instead of the "__attribute__ ..." thing. Look at
avr/pgmspace.h for the definitions.

--
G

On Wed, 2 Jun 2004, Markus Wyss wrote:

> 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
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
>
>

--
G



reply via email to

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