[En-Nut-Discussion] Timer 2 overflow interrupt

Tom Nyström m99tomny at embassaden.liu.se
Thu Mar 13 16:24:05 CET 2003


Hello everyone
 
We are using timers 1 and 3 to generate PWM signals, and timer 2 to trigger an
overflow interrupt to time a regulator function. Previously timer 3 was used for this
and the interrupt handler was registered with:
 
NutRegisterIrqHandler(&sig_OVERFLOW3, regulator, 0);
 
where "regulator" is our handler. When we changed to using timer 2 we simply wrote:
 
NutRegisterIrqHandler(&sig_OVERFLOW2, regulator, 0);
 
instead. This made the AVR-GCC compiler return:
undefined reference to 'sig_OVERFLOW2'
OVERFLOW1 and 2 do not compile, while 3 does. irqreg.h contains all these
interrupts and is included. Does anyone know why this is the case?
 
 
We have also tried using
 
NutRegisterInterrupt(IRQ_TIMER2_OVF, regulator, 0);
 
but this resulted in the compiler reporting several multiple definition errors like:
 
../../lib/gcc/atmega128\libnutdev.a(ivect16.o): In function `__vector_16':
ivect16.o(.text+0x0): multiple definition of `__vector_16'
 
 
After nosing around at AVRfreaks we found that simply using
SIGNAL(SIG_OVERFLOW2)
{
<regulator code>
}
with capital SIG does compile. Is this equivalent to using NutRegisterIrqHandler?
Anyway we don't understand why sig_OVERFLOW3 is found while 1 and 2 are not.
It seems many people have had problems with timer 2 but all the code we found was
outdated. Please help us!
 
 
This is included:
#include <string.h>
#include <stdio.h>
#include <io.h>
#include <math.h>
#include <stdlib.h>
#include <dev/nicrtl.h>
#include <dev/uartavr.h>
#include <dev/irqreg.h>
#include <sys/heap.h>
#include <sys/thread.h>
#include <sys/timer.h>
#include <sys/socket.h>
#include <sys/print.h>
#include <arpa/inet.h>
#include <net/route.h>
#include <netdb.h>
 
and these are or libs:
LIBS =  $(LIBDIR)/nutinit.o -lnutnet -lnutpro  -lnutfs -lnutos -lnutdev -lnutcrt -lm
 
 
Regards
Tom Nyström



More information about the En-Nut-Discussion mailing list