jagdfalke
16.11.2005, 15:02
Hi,
ich habe eine Zeit lang keine große Lust gehabt mich in die C-Programmierung meines AVR einzuarbeiten. Jetzt hab ich sie wieder und hab gerade die ganzen Packages unter Suse Linux 10.0 installiert, die man so braucht, also gcc-core, avr-libc, uisp, binutils. Dann wollte ich das Testprogramm das man auf http://www.tldp.org/linuxfocus/English/November2004/article352.shtml findet kompilieren, die Fehlermeldung lautete:
linux:/home/mathias/Desktop # make
avr-gcc -g -mmcu=atmega8 -Wall -Wstrict-prototypes -Os -mcall-prologues -Os -c avrm8ledtest.c
avrm8ledtest.c:27: error: syntax error before 'void'
avrm8ledtest.c:34: warning: type defaults to 'int' in declaration of 'outer1'
avrm8ledtest.c:34: warning: data definition has no type or storage class
avrm8ledtest.c:36: error: syntax error before 'while'
avrm8ledtest.c:78: error: syntax error before numeric constant
avrm8ledtest.c:78: warning: type defaults to 'int' in declaration of 'delay_ms'
avrm8ledtest.c:78: warning: function declaration isn't a prototype
avrm8ledtest.c:78: warning: data definition has no type or storage class
avrm8ledtest.c:80: error: syntax error before 'volatile'
avrm8ledtest.c:81: error: syntax error before numeric constant
avrm8ledtest.c:81: warning: type defaults to 'int' in declaration of 'delay_ms'
avrm8ledtest.c:81: warning: function declaration isn't a prototype
avrm8ledtest.c:81: warning: data definition has no type or storage class
make: *** [avrm8ledtest.o] Fehler 1
Ich poste auch mal das Makefile und den Code, weiß nicht ob das hilft aber schaden kanns ja nicht:
Make:
# makefile, written by guido socher
MCU=atmega8
CC=avr-gcc
OBJCOPY=avr-objcopy
# optimize for size:
CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues
#-------------------
all: avrm8ledtest.hex
#-------------------
help:
@echo "Usage: make all|load|load_pre|rdfuses|wrfuse1mhz|wrfuse4mhz|wr fusecrystal"
@echo "Warning: you will not be able to undo wrfusecrystal unless you connect an"
@echo " external crystal! uC is dead after wrfusecrystal if you do not"
@echo " have an external crystal."
#-------------------
avrm8ledtest.hex : avrm8ledtest.out
$(OBJCOPY) -R .eeprom -O ihex avrm8ledtest.out avrm8ledtest.hex
avrm8ledtest.out : avrm8ledtest.o
$(CC) $(CFLAGS) -o avrm8ledtest.out -Wl,-Map,avrm8ledtest.map avrm8ledtest.o
avrm8ledtest.o : avrm8ledtest.c
$(CC) $(CFLAGS) -Os -c avrm8ledtest.c
#------------------
load: avrm8ledtest.hex
./prg_load_uc avrm8ledtest.hex
# here is a pre-compiled version in case you have trouble with
# your development environment
load_pre: avrm8ledtest_pre.hex
./prg_load_uc avrm8ledtest.hex
#
loaduisp: avrm8ledtest.hex
./prg_load_uc -u avrm8ledtest.hex
# here is a pre-compiled version in case you have trouble with
# your development environment
load_preuisp: avrm8ledtest_pre.hex
./prg_load_uc -u avrm8ledtest.hex
#-------------------
# fuse byte settings:
# Atmel AVR ATmega8
# Fuse Low Byte = 0xe1 (1MHz internal), 0xe3 (4MHz internal), 0xe4 (8MHz internal)
# Fuse High Byte = 0xd9
# Factory default is 0xe1 for low byte and 0xd9 for high byte
# Check this with make rdfuses
rdfuses:
./prg_fusebit_uc -r
# use internal RC oscillator 1 Mhz
wrfuse1mhz:
./prg_fusebit_uc -w 1
# use internal RC oscillator 4 Mhz
wrfuse4mhz:
./prg_fusebit_uc -w 4
# use external 3-8 Mhz crystal
# Warning: you can not reset this to intenal unless you connect a crystal!!
wrfusecrystal:
@echo "Warning: The external crystal setting can not be changed back without a working crystal"
@echo " You have 3 seconds to abort this with crtl-c"
@sleep 3
./prg_fusebit_uc -w 0
#-------------------
clean:
rm -f *.o *.map *.out *t.hex
#-------------------
Code:
/*********************************************
* vim: set sw=8 ts=8 si :
* Author: Guido Socher, Copyright: GPL
* This program is to test the led connected to
* PC5.
* See http://linuxfocus.org/English/November2004/
* for details.
* Chip type : ATMEGA8
* Clock frequency : Internal clock 1 Mhz (factory default)
*********************************************/
#include <avr/io.h>
//#define OLD 1
#ifdef OLD
/* compatibilty macros for old style */
#ifndef cbi
*#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))*
#endif
#ifndef sbi
*#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))*
#endif
#endif /*OLD*/
*void delay_ms(unsigned short ms)*
/* delay for a minimum of <ms> */
/* with a 1Mhz clock, the resolution is 1 ms */
{
// Note: this function is faulty, see avrm8ledtest-0.2.tar.gz for
// updated code.
unsigned short outer1, outer2;
outer1 = 50;
while (outer1) {
outer2 = 1000;
while (outer2) {
while ( ms ) ms--;
outer2--;
}
outer1--;
}
}
#ifdef OLD
// old style now depricated:
*void main(void)*
{
// enable PC5 as output
sbi(DDRC,PC5);
while (1) {
// led on, pin=0
cbi(PORTC,PC5);
delay_ms(500);
// set output to 5V, LED off
sbi(PORTC,PC5);
delay_ms(500);
}
}
#else
/* new style */
*void main(void)*
{
/* INITIALIZE */
/* enable PC5 as output */
DDRC|= _BV(PC5);
/* BLINK, BLINK ... */
/* PC5 is 5 (see file include/avr/iom8.h) and _BV(PC5) is 00100000 */
while (1) {
/* led on, pin=0 */
PORTC &= ~_BV(PC5);
delay_ms(500);
/* set output to 5V, LED off */
PORTC|= _BV(PC5);
delay_ms(500);
}
}
#endif /*OLD*/
Das Problem ist eben auch, dass ich weder den Code verstehe, noch weiß was die Sache mit dem Makefile soll. Also Ahnung von Programmieren hab ich schon allerdings nur in Java :D (hilft mir ja hier nicht weiter schätz ich mal)
Ich hoff ihr könnt mir helfen.
mfg
jagdfalke
ich habe eine Zeit lang keine große Lust gehabt mich in die C-Programmierung meines AVR einzuarbeiten. Jetzt hab ich sie wieder und hab gerade die ganzen Packages unter Suse Linux 10.0 installiert, die man so braucht, also gcc-core, avr-libc, uisp, binutils. Dann wollte ich das Testprogramm das man auf http://www.tldp.org/linuxfocus/English/November2004/article352.shtml findet kompilieren, die Fehlermeldung lautete:
linux:/home/mathias/Desktop # make
avr-gcc -g -mmcu=atmega8 -Wall -Wstrict-prototypes -Os -mcall-prologues -Os -c avrm8ledtest.c
avrm8ledtest.c:27: error: syntax error before 'void'
avrm8ledtest.c:34: warning: type defaults to 'int' in declaration of 'outer1'
avrm8ledtest.c:34: warning: data definition has no type or storage class
avrm8ledtest.c:36: error: syntax error before 'while'
avrm8ledtest.c:78: error: syntax error before numeric constant
avrm8ledtest.c:78: warning: type defaults to 'int' in declaration of 'delay_ms'
avrm8ledtest.c:78: warning: function declaration isn't a prototype
avrm8ledtest.c:78: warning: data definition has no type or storage class
avrm8ledtest.c:80: error: syntax error before 'volatile'
avrm8ledtest.c:81: error: syntax error before numeric constant
avrm8ledtest.c:81: warning: type defaults to 'int' in declaration of 'delay_ms'
avrm8ledtest.c:81: warning: function declaration isn't a prototype
avrm8ledtest.c:81: warning: data definition has no type or storage class
make: *** [avrm8ledtest.o] Fehler 1
Ich poste auch mal das Makefile und den Code, weiß nicht ob das hilft aber schaden kanns ja nicht:
Make:
# makefile, written by guido socher
MCU=atmega8
CC=avr-gcc
OBJCOPY=avr-objcopy
# optimize for size:
CFLAGS=-g -mmcu=$(MCU) -Wall -Wstrict-prototypes -Os -mcall-prologues
#-------------------
all: avrm8ledtest.hex
#-------------------
help:
@echo "Usage: make all|load|load_pre|rdfuses|wrfuse1mhz|wrfuse4mhz|wr fusecrystal"
@echo "Warning: you will not be able to undo wrfusecrystal unless you connect an"
@echo " external crystal! uC is dead after wrfusecrystal if you do not"
@echo " have an external crystal."
#-------------------
avrm8ledtest.hex : avrm8ledtest.out
$(OBJCOPY) -R .eeprom -O ihex avrm8ledtest.out avrm8ledtest.hex
avrm8ledtest.out : avrm8ledtest.o
$(CC) $(CFLAGS) -o avrm8ledtest.out -Wl,-Map,avrm8ledtest.map avrm8ledtest.o
avrm8ledtest.o : avrm8ledtest.c
$(CC) $(CFLAGS) -Os -c avrm8ledtest.c
#------------------
load: avrm8ledtest.hex
./prg_load_uc avrm8ledtest.hex
# here is a pre-compiled version in case you have trouble with
# your development environment
load_pre: avrm8ledtest_pre.hex
./prg_load_uc avrm8ledtest.hex
#
loaduisp: avrm8ledtest.hex
./prg_load_uc -u avrm8ledtest.hex
# here is a pre-compiled version in case you have trouble with
# your development environment
load_preuisp: avrm8ledtest_pre.hex
./prg_load_uc -u avrm8ledtest.hex
#-------------------
# fuse byte settings:
# Atmel AVR ATmega8
# Fuse Low Byte = 0xe1 (1MHz internal), 0xe3 (4MHz internal), 0xe4 (8MHz internal)
# Fuse High Byte = 0xd9
# Factory default is 0xe1 for low byte and 0xd9 for high byte
# Check this with make rdfuses
rdfuses:
./prg_fusebit_uc -r
# use internal RC oscillator 1 Mhz
wrfuse1mhz:
./prg_fusebit_uc -w 1
# use internal RC oscillator 4 Mhz
wrfuse4mhz:
./prg_fusebit_uc -w 4
# use external 3-8 Mhz crystal
# Warning: you can not reset this to intenal unless you connect a crystal!!
wrfusecrystal:
@echo "Warning: The external crystal setting can not be changed back without a working crystal"
@echo " You have 3 seconds to abort this with crtl-c"
@sleep 3
./prg_fusebit_uc -w 0
#-------------------
clean:
rm -f *.o *.map *.out *t.hex
#-------------------
Code:
/*********************************************
* vim: set sw=8 ts=8 si :
* Author: Guido Socher, Copyright: GPL
* This program is to test the led connected to
* PC5.
* See http://linuxfocus.org/English/November2004/
* for details.
* Chip type : ATMEGA8
* Clock frequency : Internal clock 1 Mhz (factory default)
*********************************************/
#include <avr/io.h>
//#define OLD 1
#ifdef OLD
/* compatibilty macros for old style */
#ifndef cbi
*#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))*
#endif
#ifndef sbi
*#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))*
#endif
#endif /*OLD*/
*void delay_ms(unsigned short ms)*
/* delay for a minimum of <ms> */
/* with a 1Mhz clock, the resolution is 1 ms */
{
// Note: this function is faulty, see avrm8ledtest-0.2.tar.gz for
// updated code.
unsigned short outer1, outer2;
outer1 = 50;
while (outer1) {
outer2 = 1000;
while (outer2) {
while ( ms ) ms--;
outer2--;
}
outer1--;
}
}
#ifdef OLD
// old style now depricated:
*void main(void)*
{
// enable PC5 as output
sbi(DDRC,PC5);
while (1) {
// led on, pin=0
cbi(PORTC,PC5);
delay_ms(500);
// set output to 5V, LED off
sbi(PORTC,PC5);
delay_ms(500);
}
}
#else
/* new style */
*void main(void)*
{
/* INITIALIZE */
/* enable PC5 as output */
DDRC|= _BV(PC5);
/* BLINK, BLINK ... */
/* PC5 is 5 (see file include/avr/iom8.h) and _BV(PC5) is 00100000 */
while (1) {
/* led on, pin=0 */
PORTC &= ~_BV(PC5);
delay_ms(500);
/* set output to 5V, LED off */
PORTC|= _BV(PC5);
delay_ms(500);
}
}
#endif /*OLD*/
Das Problem ist eben auch, dass ich weder den Code verstehe, noch weiß was die Sache mit dem Makefile soll. Also Ahnung von Programmieren hab ich schon allerdings nur in Java :D (hilft mir ja hier nicht weiter schätz ich mal)
Ich hoff ihr könnt mir helfen.
mfg
jagdfalke