Pages: [1]   Go Down
Author Topic: Need help with interrupt  (Read 1077 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Make it real
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: September 24, 2009, 03:05:20 am by syrax » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Make it real
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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);
}
Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Make it real
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I solve the problem with AVR studio smiley) 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
« Last Edit: September 27, 2009, 04:17:48 am by syrax » Logged

London
Offline Offline
Faraday Member
**
Karma: 8
Posts: 6240
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: