[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Potential linker problems with interrupt routine
From: |
Nicolas Nickisch |
Subject: |
[avr-gcc-list] Potential linker problems with interrupt routine |
Date: |
Sun, 28 Oct 2001 07:37:47 +0100 |
Hi, even after hours of reading newsgroup subjects and trying I still have
problems with my project.
So I need help.
The error: My program uses an interrupt handler for the external interrupt
but the interupt-routine is called right at program-startup. The
main()-function is never executed.
The initialization stuff and even sei() is done in the main()-function.
After compiling and testing my program in AVR-Studio I found out, that the
interrupt handler is called directly from gcrt1.s - not the main()-function
as wanted.
As far as I know the problem comes from a linker problem: the startup code
seems not to be linked to the compiled program.
Somewhere I found I hint that the compiler switch "-c" is responsible for
the missing link (?)
So this is the make-output:
avr-gcc -c -g -O -Wall -Wstrict-prototypes -Wa,-ahlmns=pcf-test.lst -mmcu=at
90s8
515 -I. pcf-test.c -o pcf-test.o
pcf-test.c: In function `_interrupt0_':
pcf-test.c:182: warning: array subscript has type `char'
avr-gcc -c -g -O -Wall -Wstrict-prototypes -Wa,-ahlmns=lcd.lst -mmcu=at90s85
15 -
I. lcd.c -o lcd.o
avr-gcc -c -g -O -Wall -Wstrict-prototypes -Wa,-ahlmns=timer.lst -mmcu=at90s
8515
-I. timer.c -o timer.o
avr-gcc -Wa,-gstabs -mmcu=at90s8515 -c -o i2cmas.o i2cmas.S
avr-gcc i2cmas.o pcf-test.o lcd.o
timer.o -Wl,-Map=PCF8574.map,--cref -mmcu=at
90s8515 -o PCF8574.elf
avr-objcopy -O ihex -R .eeprom PCF8574.elf PCF8574.rom
avr-objcopy -j
.eeprom --set-section-flags=.eeprom="alloc,load" --change-section
-lma .eeprom=0 -O ihex PCF8574.elf PCF8574.eep
Errors: none
elfcoff PCF8574.elf coff PCF8574.cof PCF8574.sym
Ended
cp Coff\PCF8574.cof .
cp Coff\\*sym .
cp Coff\\*S .
rm i2cmas.o
And here we have all the "-c"s. I think I eliminated all the "-c" in make1,
make2 and makefile.
For additionial information:
pcf-test.c contains the main()-function and the interrupt-handler and calls
functions in other files
lcd.c contains functions for output to an lcd-display
timer. c contains a delay-fnction
i2cmas.S is a assembler library from P. Fleury
The makefile:
# Simple Makefile
# Volker Oth (c) 1999 modified by N. Nickisch 2001
include $(AVR)/include/make1
########### change this lines according to your project ##################
#put the name of the target mcu here (at90s8515, at90s8535, attiny22,
atmega603 etc.)
MCU = at90s8515
#put the name of the target file here (without extension)
TRG = PCF8574
#put your C sourcefiles here
SRC = timer.c lcd.c pcf-test.c
#put additional assembler source file here
ASRC = i2cmas.s
#additional libraries and object files to link
LIB =
#additional includes to compile
INC =
#compiler flags
CPFLAGS = -g -O -Wall -Wstrict-prototypes -Wa,-ahlmns=$(<:.c=.lst)
#linker flags
LDFLAGS = -Wl,-Map=$(TRG).map,--cref
########### you should not need to change the following line #############
include $(AVR)/include/make2
###### dependecies, add any dependencies you need here ###################
#sercomm.o : sercomm.c
timer.o : timer.c timer.h
lcd.o: timer.h timer.c lcd.c
pcf-test.o :pcf-test.c
$(TRG).o : $(TRG).c
OUT = coff
The make1:
# GCC-AVR standard Makefile part 1
# Volker Oth 1/2000
# Modified by AVRfreaks.net for smoother integrasjon with AVR Studio.
(06/2001)
###### define some variables based on the AVR base path in $(AVR) #######
CC = avr-gcc
AS = avr-gcc -x assembler-with-cpp
RM = rm -f
RD = rm -r
RN = mv
CP = cp
BIN = avr-objcopy
ELFCOF = elfcoff
SIZE = avr-size
INCDIR = .
LIBDIR = $(AVR)/avr/lib
SHELL = $(AVR)/bin/sh.exe
###### output format can be srec, ihex (avrobj is always created) #######
FORMAT = ihex
########################## default mcu type #############################
MCU = at90s8515
####################### default compiler flags ##########################
CPFLAGS = -g -O3 -Wall -Wstrict-prototypes -Wa,-ahlms=$(<:.c=.lst)
####################### default assembler flags #########################
ASFLAGS = -Wa,-gstabs
########################## default linker flags #########################
LDFLAGS = -Wl,-Map=$(TRG).map,--cref
The make 2:
# GCC-AVR standard Makefile part 2
# Volker Oth 1/2000
# Modified by AVRfreaks.net for smoother integrasjon with AVR Studio.
(06/2001)
#define all project specific object files
OBJ = $(ASRC:.s=.o) $(SRC:.c=.o)
CPFLAGS += -mmcu=$(MCU)
ASFLAGS += -mmcu=$(MCU)
LDFLAGS += -mmcu=$(MCU)
#this defines the aims of the make process
all: $(TRG).elf $(TRG).rom $(TRG).eep $(TRG).ok $(TRG).cof
#compile: instructions to create assembler and/or object files from C source
%o : %c
$(CC) -c $(CPFLAGS) -I$(INCDIR) $< -o $@
#neu $(CC) $(CPFLAGS) -I$(INCDIR) $< -o $@
%s : %c
$(CC) -S $(CPFLAGS) -I$(INCDIR) $< -o $@
#assemble: instructions to create object file from assembler files
%o : %s
$(AS) -c $(ASFLAGS) -I$(INCDIR) $< -o $@
#neu $(AS) $(ASFLAGS) -I$(INCDIR) $< -o $@
#link: instructions to create elf output file from object files
%elf: $(OBJ)
$(CC) $(OBJ) $(LIB) $(LDFLAGS) -o $@
#create bin (ihex, srec) file from elf output file
%rom: %elf
$(BIN) -O $(FORMAT) -R .eeprom $< $@
%eep: %elf
$(BIN) -j
.eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma
.eeprom=0 -O $(FORMAT) $< $@
%cof: %elf
$(ELFCOF) $< $(OUT) $@ $*sym
$(CP) Coff\$@ .
$(CP) Coff\\*sym .
$(CP) Coff\\*S .
#If all other steps compile ok then echo "Errors: none".
#Necessary for AVR Studio to understand that everything went ok.
%ok:
@echo "Errors: none"
#make instruction to delete created files
clean:
$(RM) $(OBJ)
$(RM) $(SRC:.c=.s)
$(RM) $(SRC:.c=.lst)
$(RM) $(TRG).map
$(RM) $(TRG).elf
$(RM) $(TRG).obj
$(RM) $(TRG).a90
$(RM) $(TRG).hex
$(RM) $(TRG).avd
$(RM) $(TRG).cof
$(RM) $(TRG).eep
$(RM) $(TRG).rom
$(RM) $(TRG).sym
$(RM) $(TRG).c_sym
$(RM) *.bak
$(RM) *.log
$(RD) Coff
size:
$(SIZE) $(TRG).elf
This project has been started months ago.
The first test runs worked. Now I returned to the project after downloading
elfcoff and installing the newest avr-gcc-package.
maybe the program was first compiled with an older version of avr-gcc.
Nicolas Nickisch
- [avr-gcc-list] Potential linker problems with interrupt routine,
Nicolas Nickisch <=