Author Topic: timer.c:98: error: 'TIMSK' undeclared (first use in this function)  (Read 9672 times)

0 Members and 1 Guest are viewing this topic.

Offline TazdevilTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
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)));
}

Offline Razor Concepts

  • Supreme Robot
  • *****
  • Posts: 1,856
  • Helpful? 53
    • RazorConcepts
Re: timer.c:98: error: 'TIMSK' undeclared (first use in this function)
« Reply #1 on: May 29, 2009, 02:39:26 AM »
You may want to use the timerx8 files instead, they work fine with the mega168.

Offline TazdevilTopic starter

  • Jr. Member
  • **
  • Posts: 11
  • Helpful? 0
Re: timer.c:98: error: 'TIMSK' undeclared (first use in this function)
« Reply #2 on: May 29, 2009, 07:21:15 AM »
I see looks like it has all the changes I was going to make to the timer.c to make it compile without errors?

From what I can see all the functions seem to exist. What might be the downside to using this and compatability back to this designed to use the timer.c or timer128 for that matter. Although from a quick look timer128 appears to have the same issues as timer.c for the mega168.

Thanks I'm am only a week into learning this so I am just getting started.