Witam!
Dotychczas programowałem moje projekty w AVRASM ale chciałęm się przesiąść na AVRC no i nie mam takiego problemu że nie wiem jak zdefiniować mikrokontroler.
Pisze w AVRGCC z konsoli bez WINAVR tak:
KOD:
/* "led.c" - programik do testowania środowiska WinAVR */
/* układ ATmega 1MHz */
/* PB0,PB1 - diody LED; PD0 - przycisk */
#define F_CPU 1000000L
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRB |= _BV(0)|_BV(1);
PORTB |= _BV(0);
PORTB &= ~_BV(1);
DDRD &= ~_BV(0);
PORTD |= _BV(0);
while (1)
{
PORTB ^=_BV(0);
PORTB ^=_BV(1);
_delay_ms((PIND & _BV(0))? 1000: 200);
}
}
LOG KOMPILACJI:
uzytkownik@Dell-Latitude-E5410:~/projekty/projektc$ avr-gcc main.c
In file included from main.c:7:0:
/usr/lib/avr/include/avr/io.h:623:6: warning: #warning "device type not defined" [-Wcpp]
# warning "device type not defined"
^
In file included from main.c:8:0:
/usr/lib/avr/include/util/delay.h:112:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed" [-Wcpp]
# warning "Compiler optimizations disabled; functions from <util/delay.h> won't
^
main.c: W funkcji ‘main’:
main.c:12:5: error: ‘DDRB’ undeclared (first use in this function)
DDRB |= _BV(0)|_BV(1);
^
main.c:12:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:13:5: error: ‘PORTB’ undeclared (first use in this function)
PORTB |= _BV(0);
^
main.c:15:5: error: ‘DDRD’ undeclared (first use in this function)
DDRD &= ~_BV(0);
^
main.c:16:5: error: ‘PORTD’ undeclared (first use in this function)
PORTD |= _BV(0);
^
main.c:23:20: error: ‘PIND’ undeclared (first use in this function)
_delay_ms((PIND & _BV(0))? 1000: 200);
Dziękuję za każdą pomoc!