Mam pewien problem. Pobrałem z internetu bibliotekę do LCD HD44780, działa ładnie ale pod m.in. ATMega32 a pod ATMega8 nie kompiluje się. Postanowiłem ją poprawić i jak łatwo się domyśleć nadal nie działa ;/ Kompiluje się teraz ale nie nic nie wyświetla. Powiedzcie gdzie popełniłem błąd?
Kod po zmianie:
Kod przed zmianą:
Błąd przy kompilacji oryginału:
Kod po zmianie:
#include "delay.h"
volatile uint16_t delayCount;
void initializeDelayTimerMicrosecond(void)
{
TCCR1A = 0;
TIFR |= _BV(OCF1A);
TCCR1A = _BV(WGM11) | _BV(CS01);
TCNT1L = 0;
TIMSK |= _BV(OCIE1A);
OCR1AL = OCR_1MICROSECOND;
}
void initializeDelayTimerMillisecond(void)
{
TCCR1A = 0;
TIFR |= _BV(OCF1A);
TCCR1A = _BV(WGM11) | _BV(CS02);
TCNT1L = 0;
TIMSK |= _BV(OCIE1A);
OCR1AL = OCR_1MILLISECOND;
}
void runDelay(uint16_t delayUnits)
{
TCNT1L = 0;
delayCount = 0;
while (delayCount != delayUnits)
;
}
void delay50us(uint16_t delayUnits)
{
runDelay(delayUnits);
}
Kod przed zmianą:
#include "delay.h"
volatile uint16_t delayCount;
void initializeDelayTimerMicrosecond(void)
{
TCCR0 = 0;
TIFR |= _BV(OCF0);
TCCR0 = _BV(WGM01) | _BV(CS01);
TCNT0 = 0;
TIMSK |= _BV(OCIE0);
OCR0 = OCR_1MICROSECOND;
}
void initializeDelayTimerMillisecond(void)
{
TCCR0 = 0;
TIFR |= _BV(OCF0);
TCCR0 = _BV(WGM01) | _BV(CS02);
TCNT0 = 0;
TIMSK |= _BV(OCIE0);
OCR0 = OCR_1MILLISECOND;
}
void runDelay(uint16_t delayUnits)
{
TCNT0 = 0;
delayCount = 0;
while (delayCount != delayUnits)
;
}
void delay50us(uint16_t delayUnits)
{
runDelay(delayUnits);
}
Błąd przy kompilacji oryginału:
Build started 17.1.2011 at 18:38:02
avr-gcc -mmcu=atmega8 -Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT delay.o -MF dep/delay.o.d -c ../delay.c
../delay.c: In function 'initializeDelayTimerMicrosecond':
../delay.c:49: error: 'WGM01' undeclared (first use in this function)
../delay.c:49: error: (Each undeclared identifier is reported only once
../delay.c:49: error: for each function it appears in.)
../delay.c:56: error: 'OCIE0' undeclared (first use in this function)
../delay.c:60: error: 'OCR0' undeclared (first use in this function)
../delay.c: In function 'initializeDelayTimerMillisecond':
../delay.c:79: error: 'OCF0' undeclared (first use in this function)
../delay.c:84: error: 'WGM01' undeclared (first use in this function)
../delay.c:91: error: 'OCIE0' undeclared (first use in this function)
../delay.c:95: error: 'OCR0' undeclared (first use in this function)
make: *** [delay.o] Error 1
Build failed with 9 errors and 0 warnings...