[Top][All Lists]

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

[avr-gcc-list] global variables

From: Tomas Krcka
Subject: [avr-gcc-list] global variables
Date: Fri, 19 Aug 2005 12:58:30 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

   I have a problem with global variables in my project.
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;
It's a simplified example, but doesn't work too.

If I call these functions in main.c
 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

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

Do you have  ideas?



reply via email to

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