I am trying to talk to a ds1631 using ds1631test.c from the avr examples. I am using atmega168.
There appears to be some errors when compiling starting with the TIMSK which I think I need to change to TIMSK1 and TIMSK2. I am kind of guessing the TCCR0 needs to be TCRR0A and then B.
Is this common to have issue with compiling and small changes need to be made.
errors
timer.c:98: error: 'TIMSK' undeclared (first use in this function)
timer.c:98: error: (Each undeclared identifier is reported only once
timer.c:98: error: for each function it appears in.)
timer.c: In function 'timer1Init':
timer.c:109: error: 'TIMSK' undeclared (first use in this function)
timer.c: In function 'timer2Init':
timer.c:118: error: 'TIMSK' undeclared (first use in this function)
timer.c: In function 'timer0SetPrescaler':
timer.c:127: error: 'TCCR0' undeclared (first use in this function)
timer.c: In function 'timer2SetPrescaler':
timer.c:140: error: 'TCCR2' undeclared (first use in this function)
timer.c: In function 'timer0GetPrescaler':
timer.c:147: error: 'TCCR0' undeclared (first use in this function)
timer.c: In function 'timer2GetPrescaler':
timer.c:163: error: 'TCCR2' undeclared (first use in this function)
timer.c:464: warning: 'SIG_OUTPUT_COMPARE2' appears to be a misspelled signal handler
The below code is from timer.c
ln93
void timer1Init(void)
{
// initialize timer 1
timer1SetPrescaler( TIMER1PRESCALE ); // set prescaler
outb(TCNT1H, 0); // reset TCNT1
outb(TCNT1L, 0);
sbi(TIMSK, TOIE1); // enable TCNT1 overflow
}
#ifdef TCNT2 // support timer2 only if it exists
void timer2Init(void)
{
// initialize timer 2
timer2SetPrescaler( TIMER2PRESCALE ); // set prescaler
outb(TCNT2, 0); // reset TCNT2
sbi(TIMSK, TOIE2); // enable TCNT2 overflow
timer2ClearOverflowCount(); // initialize time registers
}
#endif
void timer0SetPrescaler(u08 prescale)
{
// set prescaler on timer 0
outb(TCCR0, (inb(TCCR0) & ~TIMER_PRESCALE_MASK) | prescale);
}
void timer1SetPrescaler(u08 prescale)
{
// set prescaler on timer 1
outb(TCCR1B, (inb(TCCR1B) & ~TIMER_PRESCALE_MASK) | prescale);
}
#ifdef TCNT2 // support timer2 only if it exists
void timer2SetPrescaler(u08 prescale)
{
// set prescaler on timer 2
outb(TCCR2, (inb(TCCR2) & ~TIMER_PRESCALE_MASK) | prescale);
}
#endif
u16 timer0GetPrescaler(void)
{
// get the current prescaler setting
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR0) & TIMER_PRESCALE_MASK)));
}
u16 timer1GetPrescaler(void)
{
// get the current prescaler setting
return (pgm_read_word(TimerPrescaleFactor+(inb(TCCR1B) & TIMER_PRESCALE_MASK)));
}
#ifdef TCNT2 // support timer2 only if it exists
u16 timer2GetPrescaler(void)
{
//TODO: can we assume for all 3-timer AVR processors,
// that timer2 is the RTC timer?
// get the current prescaler setting
return (pgm_read_word(TimerRTCPrescaleFactor+(inb(TCCR2) & TIMER_PRESCALE_MASK)));
}