NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Support Forum » TCCR0 undefined error

April 17, 2011
by oldphart
oldphart's Avatar

I am trying to set up an interrupt using TIMER0 with the ATmega168 chip from Nerdkits. I have included <avr/io.h> and <avr/interrupt.h> but the preprocessor is throwing an undefined error for TCCR0 and TIMSK declarations, but it is ok with the TCNT0 declaration. Searched the include directory for TCCR0 and found it in numerous header files specific to various microcontroller chips with a caveat that the header must not be include directly, only through "io.h". I have no clue what the problem might be. Anybody know what I am missing here? TIA. -Dave

// levelsensor.c
// using NerdKits with ATmega168
// Dave Devoy

    #define F_CPU 14745600

#include <stdio.h>
#include <math.h>

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <inttypes.h>

#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"
#include "../libnerdkits/uart.h"


// prescaler = FCPU/1024

  TCCR0 |= (1<<CS02) | (CS01);

  // Enable overflow interrupt enable
  TIMSK |= (1<<TOIE0);

  // Initialize counter
  TCNT0 = 0;

  // Enable Global Interrupts
April 17, 2011
by oldphart
oldphart's Avatar

Sorry, Nevermind. Was using sample code from a different MC chip. I need to read the data sheet <sigh>. I need something like TCCR0A for the ATmega169 chip. Sorry for barking in the wrong woodlot! -Dave

Post a Reply

Please log in to post a reply.

Did you know that you can make a spooky Halloween Jack-O-Lantern with a microcontroller? Learn more...