ATtiny 85 Code Compile Error (multiple definition)

Using Arduino IDE 1.0.5r2 on Windows
this is the error message I'm getting:

core.a(wiring.c.o): In function __vector_5': C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino/wiring.c:49: multiple definition of __vector_5'
sketch_sep02b.cpp.o:C:\Program Files (x86)\Arduino/sketch_sep02b.ino:88: first defined here

The code I'm using was originally for the Arduino Atmega 168, I've changed it to use Timer0 on the ATtiny 85 instead of
the Timer2 on the 168. The original can be found here:

Here is my version, thanks in advance!!! :


  • Timer0 generates the 31250 KHz Clock Interrupt

#include "avr/pgmspace.h"

// Table of 256 sine values (one sine period) which is stored in flash memory.
PROGMEM prog_uchar sine256[] = {

#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
byte bb;

double dfreq;
// const double refclk=31372.549; // =16MHz / 510
const double refclk=31376.6; // measured

// variables used inside interrupt service declared as voilatile
volatile byte icnt; // var inside interrupt
volatile byte icnt1; // var inside interrupt
volatile byte c4ms; // counter incremented all 4ms
volatile unsigned long phaccu; // phase accumulator
volatile unsigned long tword_m; // dds tuning word m

void setup()
pinMode(0, OUTPUT); // pin0= PWM output / frequency output


// disable interrupts to avoid timing distortion
cbi (TIMSK,TOIE0); // disable Timer0
sbi (TIMSK,TOIE0); // enable Timer0 Interrupt

dfreq=2000.0; // initial output frequency = 2000.o Hz
tword_m=pow(2,32)*dfreq/refclk; // calulate DDS new tuning word

void loop()
// timer0 setup
// set prscaler to 1, PWM mode to phase correct PWM, 16000000/510 = 31372.55 Hz clock
void Setup_timer0() {

// Timer0 Clock Prescaler to : 1
sbi (TCCR0B, CS00);
cbi (TCCR0B, CS01);
cbi (TCCR0B, CS02);

// Timer0 PWM Mode set to Phase Correct PWM
cbi (TCCR0A, COM0A0); // clear Compare Match
sbi (TCCR0A, COM0A1);

sbi (TCCR0A, WGM00); // Mode 1 / Phase Correct PWM
cbi (TCCR0A, WGM01);
cbi (TCCR0B, WGM02);


// Timer0 Interrupt Service at 31372,550 KHz = 32uSec
// this is the timebase REFCLOCK for the DDS generator
// FOUT = (M (REFCLK)) / (2 exp 32)
// runtime : 8 microseconds ( inclusive push and pop)
ISR(TIMER0_OVF_vect) {

phaccu=phaccu+tword_m; // soft DDS, phase accu with 32 bits
icnt=phaccu >> 24; // use upper 8 bits for phase accu as frequency information
// read value from ROM sine table and send to PWM DAC
OCR0A=pgm_read_byte_near(sine256 + icnt);

if(icnt1++ == 125) { // increment variable c4ms all 4 milliseconds

tword_m=pow(2,32)*dfreq/refclk;  // calulate DDS new tuning word

No. Do NOT use pow() to raise 2 to any power. Use bit shifting. pow() returns floating point values which may not be accurate.

I'm going go get rid of the entire tuning with analogue input section for a fixed frequency output, this wouldn't be what's causing the compile error though?

Use this core...