[Top][All Lists]

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

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

From: Stein Haaland
Subject: [avr-gcc-list] Re: global variables - II
Date: Wed, 29 Sep 2004 13:06:39 +0200
User-agent: KMail/1.6.1

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)


reply via email to

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