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

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

[avr-gcc-list] How to port "char flash *" used with IAR to avr-gcc?


From: Günter Dannoritzer
Subject: [avr-gcc-list] How to port "char flash *" used with IAR to avr-gcc?
Date: Wed, 20 Oct 2004 15:43:53 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910

Hi,

I have some code that was developed under IAR. Now I want to port it to avr-gcc and have some trouble getting a print function to work.

This is the function, used under IAR:

        void PrintStr( char flash *str )
        {
                unsigned char count=0;

                while ((str[count] != '\0') && (count != 64)) {
                UartTransmitByte(str[count++]);
                }
        }


It prints out the given string to the serial port.

To compile it with avr-gcc I changed function parameter type to:

        void PrintStr( char * str)

leaving the remaining code in the function body the same.

It does not print out any text over the serial port.

I searched for some information of the "flash" type and in the Atmel application note #35 it explains that this is a pointer to a flash location.

The way I changed that now is, that I made it a pointer to a RAM location.

From the explanation in the Atmel application note it seems like that after reset the whole code gets copied from the flash to the RAM. So if I have a PrintStr("Hello World") function call, the "Hello World" string should get copied to the RAM as well or am I missing here something?

Reading through the libc documentation concerning reading data from the flash, I guess the other way to do this with avr-gcc would be to use the PGM_P and pgm_read_byte function to leave the string in the flash. Would that be the equivalent to the IAR flash pointer?

Can anybody give me a hint how to fix this?

Thanks for the help.

Guenter




reply via email to

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