[Top][All Lists]

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

Re: [avr-gcc-list] Re: global variables - II

From: Mikael Krus
Subject: Re: [avr-gcc-list] Re: global variables - II
Date: Wed, 29 Sep 2004 12:29:19 +0200
User-agent: Mozilla Thunderbird 0.5 (Windows/20040207)

Do you include all needed sections when creating your binary?
avr-objcopy -j .text -j .data -O ihex input_file output_file.hex

I guess your character array (or string) goes into the .data section.

/Mikael Krus

Stein Haaland wrote:

My problem is not really connected to the EEPROM writing, more
to the definition of global variables, thus the subject.

The code snippet below illustrates the problem. The Port (on a STK 500) does not sequentially output the character string as expected; it rather toggles between 0x00 and 0xFF.
I can set the port to any value, using local variables.
Is there anything I have misunderstood in the use of global variables and avr-gcc ?

#  include <avr/io.h>

char text[] = "This is a test";    // test string or uint8 array or...

void wait(uint16_t ms)
// a multiple do while loop to create a delay. Works !

void write_text_to_port() {
 uint8_t i;
for (i=0; i<10; i++) {
   PORTB = ~text[i];            // Port B = character[i]
   wait(400);                   // ...wait....
   PORTB = ~0x00;               // turn of all leds
   wait(400);                   // ... wait ...

int main(void)
 DDRB = 0xFF;                   // set to output



Your character matrix is very large. Isn't it in fact larger than the available amount of SRAM in AT90S8515????
/Mikael Krus

Yes, thanks for pointing out. This is a side issue though.

Is DDRC == 0xFF ?

Yes, DDR is set.
If you want to store data in the EEPROM once, you could also build a Intel Hex File ... Bernard

This is my intention - any examples references on how to do this ?

(Sys :
MDK Linux 10.0.
avr-gcc (GCC) 3.3.2 objcopy 2.14 20030612
uisp version 20040311
STK500 testboard, AT90S8515)


avr-gcc-list mailing list

reply via email to

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