PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Undefined Reference... anscheinend keine Header-Files gefun.



Tirador
10.09.2007, 18:48
Hi, bin Anfänger und habe ein Problem. Anscheinend werden keine Header-Files gefunden: Versuche folgendes zu kompilieren:


/*
* blink.c
* ATtiny2313 mit 1 MHz
* PORTB wird ueber ein Timer alle 0.263s ein- und ausgeschaltet. Das entspricht 3.81Hz
*/

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>

SIGNAL (SIG_TIMER0_OVF)
{
PORTB =~ PORTB; // PORTB inventieren
}

int main()
{
DDRB = 0xFF; // PORTB als Ausgang schalten
PORTB = 0x00; // Alle Ausgaenge auf 0 schalten

TCCR0B |= (1 << CS02) | (1 << CS00); //Prescaler auf 1024 stellen
TIMSK |= (1 << TOIE0); // Timer 0 Overflow Interrupt enable

sei(); // Interrupts einschalten

for(;;); //ever
}

Ausgabe von Programmers-Notepad:


> "make.exe" all

-------- begin --------
avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling: blink.c
avr-gcc -c -mmcu=atmega32 -I. -gstabs -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=blink.lst -std=gnu99 -Wp,-M,-MP,-MT,blink.o,-MF,.dep/blink.o.d blink.c -o blink.o
blink.c:11: warning: 'SIG_TIMER0_OVF' appears to be a misspelled signal handler
blink.c:17: warning: function declaration isn't a prototype
blink.c: In function 'main':
blink.c:21: error: 'TCCR0B' undeclared (first use in this function)
blink.c:21: error: (Each undeclared identifier is reported only once
blink.c:21: error: for each function it appears in.)
make.exe: *** [blink.o] Error 1

> Process Exit Code: 2
> Time Taken: 00:01


Das gleiche bei anderen "simplen" Programmen. Wo nur outp() z.B. benutzt wird. Anscheinend werden die Header-Files nicht richtig gefunden.

SprinterSB
10.09.2007, 18:58
-- es heisst TCCR0 (ATmega32 hat kein TCCR0B)
-- es heisst TIMER0_OVF_vect oder SIG_OVERFLOW0

ähhh.. du willst nen ATtiny2313? dann musst du das avr-gcc auch sagen (bzw ihm über's Makefile sagen lassen). Momentan übersetzt du für ATmega32.

Für die Namen von SFRs/ISRs guckst du

<GCC_INSTALL_DIR>/avr/include/avr/iom32.h (für ATmega32)
<GCC_INSTALL_DIR>/avr/include/avr/iotn2313.h (für ATtiny2313)

Tirador
10.09.2007, 19:00
Ok ich probiers mal aus. Hat funktioniert, Danke!

Was sollte ich denn als erstes machen, um voll hinter die ganzen Möglichkeiten durchzusteigen? Wo finde ich eine Übersicht aller Funktionen in C, die ich vorgegeben habe?

Und was ist an folgendem Code falsch?


#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>

int main (void)
{
outp(0xFE,DDRA); //PortA: Pin0: Input, Pin1..7: Output
outp(0xFF,PORTA); //PortA: Pin0: pull up, Pin1..7: high = LED off

while(1)
{
if(bit_is_set (PINA,0)) //check if PinA0 is high
{
cbi(PORTA,1); //clear PinA1 = LED on
}
else
{
sbi(PORTA,1); //set PinA1 = LED off
}
}
}

Ausgabe:


-------- begin --------
avr-gcc (GCC) 4.1.2 (WinAVR 20070525)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling: test.c
avr-gcc -c -mmcu=atmega32 -I. -gstabs -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=test.lst -std=gnu99 -Wp,-M,-MP,-MT,test.o,-MF,.dep/test.o.d test.c -o test.o
test.c: In function 'main':
test.c:5: warning: implicit declaration of function 'outp'
test.c:12: warning: implicit declaration of function 'cbi'
test.c:16: warning: implicit declaration of function 'sbi'

Linking: test.elf
avr-gcc -mmcu=atmega32 -I. -gstabs -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=test.o -std=gnu99 -Wp,-M,-MP,-MT,test.o,-MF,.dep/test.elf.d test.o --output test.elf -Wl,-Map=test.map,--cref -lm
test.o: In function `main':
test.c:5: undefined reference to `outp'
test.c:6: undefined reference to `outp'
test.c:12: undefined reference to `cbi'
test.c:16: undefined reference to `sbi'
make.exe: *** [test.elf] Error 1

> Process Exit Code: 2
> Time Taken: 00:00

izaseba
10.09.2007, 19:12
Was ist an folgendem Code falsch?

1. #include <avr/signal.h> ist veraltet
2. outp(0xFE,DDRA); ist veraltet
3. cbi(PORTA,1); ist veraltet
4. sbi(PORTA,1); ist veraltet

SprinterSB
10.09.2007, 19:12
(Siehe mein Beitrag oben, hab ich nacheditiert)

Du verwendest alte Makros, die zu einer alten avr-gcc-Version gehören.

In der 4.x gibt's diese Makros AFAIK net mehr
--> selber nachdefinieren oder wie's alle Welt macht werden Bits gesetzt/gelöscht durch Standard-C-Konstrukte.
--> signal.h braucht's auch net mehr, die Makros sind jetzt in interrupt.h