avr-chat
[Top][All Lists]
Advanced

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

[avr-chat] global variables - avr-gcc


From: Tomas Krcka
Subject: [avr-chat] global variables - avr-gcc
Date: Sun, 21 Aug 2005 09:49:51 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

Hi!
   I have a problem with global variables -  avr-gcc compiler.

The problem is:

I have file system.c
       byte proc_tbl[MAX_PROCESS];  //it's global variable in system.c
       void System_Init(void){
          int i;
           for (i = 0;i < MAX_PROCESS; i++)
             proc_tbl[i] = NOT_USED;
       }
and function

      byte Create_Process(void){
           int i;
           for (i=0; i < MAX_PROCESS; i++)
              if (proc_tbl[i] == NOT_USED){
                     proc_tbl[i] = USED;
                     return(OK);
              }
       return(ERROR);
      }
It's a simplified example, but doesn't work too.

If I call these functions in main.c
        System_Init();
        Create_Process();
 function Create_Process return ERROR permanently.

If global variable proc_tbl is static, it's work fine.
And If I change sequence of linking obj files, system.o is first, It's
work fine too.

Compiling and linking :  example for all files
main.o : main.c
    $(CC) $(CFLAGS) -Os -c main.c

main.out: main.o all obj files
    $(CC) $(CFLAGS) -o main.out main.o all obj files
main_eeprom.hex: main.out
    $(OBJCOPY) -j .eeprom -O ihex main.out main_eeprom.hex
main_flash.hex: main.out
    $(OBJCOPY) -R .eeprom -O ihex main.out main_flash.hex

CFLAGS=-g -mmcu=$(MCU) -DF_CPU=14.7456E6 -Wstrict-prototypes
-Wunknown-pragmas -O0 -mcall-prologues

and avr-gcc for linux version 3.4.1

I don't know what's wrong. Maybe some error with memory.

Do you have any ideas?

Thanks.

Tom










reply via email to

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