Go Down

Topic: Need help with interrupt (Read 1 time) previous topic - next topic

syrax

Sep 24, 2009, 10:03 am Last Edit: Sep 24, 2009, 10:05 am by syrax Reason: 1
I can't handle ISR(TIMER0_OVF_vect) routine, can some help me with interrupt vectors

This is the message :
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\build46918.tmp\core.a(wiring.c.o): In function `__vector_9':


C:\Program Files\arduino-0016-win\arduino-0016\hardware\cores\arduino/wiring.c:45: multiple definition of `__vector_9'
I look in datasheet and see this vector 9 is for timer1 !!! Why?

Thanks and regards from Bulgaria

syrax

Here is my test code

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#define F_CPU 16000000UL
#define INIT_TIMER_COUNT 6
#define RESET_TIMER0 TCNT0 = INIT_TIMER_COUNT

int counter;


ISR(__vector_10){
 RESET_TIMER0;
 PORTB ^= (1 << 0);
}


void setup(){
 DDRB |= 0xff; //PORT B OUTPUT
 RESET_TIMER0;
 TCCR0 |= 0x02; //Internal clock w 8 prescaller
 TIMSK |= 0x01; //enable overflow interrupt
 TCCR0 |= 0x02; //Internal clock w 8 prescaller  
 sei();
}

void loop(){
 PORTB ^= (1 << 5);
 _delay_us(300);
}

mem

Timer0 is used by arduino for the millis and delay functions so is best left alone.
There are library routines in the playground that give you access to timer interrupt functionality without having to understand the low level registers. See FrequencyTimer2 for one example.

Perhaps you might say what it is you want to do?

syrax

#3
Sep 27, 2009, 11:15 am Last Edit: Sep 27, 2009, 11:17 am by syrax Reason: 1
I solve the problem with AVR studio :)) I think is better to use if you know how becouse the arduino code is BIGGER and little slow. My program is about 5K in pure C++ and have to write more code to finish my program . When i use direct access to register from arduino  this make program smaller.

And last question is possible to remove from arduino millis and free this timer, asking becouse this is primitive time0 and is great from refreshing if you have display, buttons ... The idea is to run it on background and dont tnink it more in main code


Is the delay() use timer0 ????  :o   I use util/delay.h with no timers
Regards from Bulgaria

mem

Yes, delay uses millis which uses timer 0

This is not intended top be impolite but if you are not using the Arduino IDE or any arduino functions, your questions may me more suited for the avrfreaks forum.

Go Up