Witam.
Jestem nowicjuszem w świecie mikrokontrolerów.
Chciałem skompilować ten kod:
lecz wyświetla mi to:
Kod pochodzi ze strony http://www.patron.ehost.pl/patron/artykuly/vinavr/AVR_tutorial.htm a program to WinAVR.
Proszę o pomoc.
Jestem nowicjuszem w świecie mikrokontrolerów.
Chciałem skompilować ten kod:
#include <avr/io.h>
/******************************************************
Definicje stałych
*******************************************************/
#define F_CPU 1000000 /* 1MHz zegar procesora */
#define CYCLES_PER_US ((F_CPU+500000)/1000000) /* cpu cycles per microsecond */
/**************************************************************
Koniec definicji stałych
**************************************************************/
//definiujemy stany portu sterującego diodą LED
#define LED_ON sbi(DDRB,PB1);sbi(PORTB,PB1)
#define LED_OFF sbi(DDRB,PB1);cbi(PORTB,PB1)
// Piszemy procedury opóźnienia czasowego
void delay(unsigned int us)
{
unsigned int delay_loops;
register unsigned int i;
delay_loops = (us+3)/5*CYCLES_PER_US; // +3 for rounding up (dirty)
for (i=0; i < delay_loops; i++) {};
}
void delayms(unsigned int ms)
{
unsigned int i;
for (i=0;i<ms;i++)
{
delay(999);
asm volatile (
"WDR"::);
}
}
int main (void)
{
for (;;)
{
LED_ON;
delayms(1000);
LED_OFF;
delayms(1000);
}
return (0);
}
lecz wyświetla mi to:
> "make.exe" all
avr-gcc -g -Wall -O2 -mmcu=atmega8 -c -o led.o led.c
led.c: In function 'main':
led.c:71: warning: implicit declaration of function 'sbi'
led.c:75: warning: implicit declaration of function 'cbi'
avr-gcc -g -Wall -O2 -mmcu=atmega8 -Wl,-Map,led.map -o led.elf led.o
led.o: In function `main':
C:\AVR_projekty\LED/led.c:65: undefined reference to `sbi'
C:\AVR_projekty\LED/led.c:65: undefined reference to `sbi'
C:\AVR_projekty\LED/led.c:75: undefined reference to `sbi'
C:\AVR_projekty\LED/led.c:75: undefined reference to `cbi'
make.exe: *** [led.elf] Error 1
> Process Exit Code: 2
> Time Taken: 00:04
Kod pochodzi ze strony http://www.patron.ehost.pl/patron/artykuly/vinavr/AVR_tutorial.htm a program to WinAVR.
Proszę o pomoc.
