First of all, this is not how the input capture on the timer is intended to be used, but it can work. I would go for the IRQ pin or the keyboard interrupts instead of the timer. The IRQ is the simplest.
There is more than one way to do interrupts in C. Here is the way I do it:
First of all, you have to enable interrupts in your main program with a line like this:
asm cli;
They start out being disabled, so you have to do this to get them to work.
In the C file, I do it like this:
#pragma TRAP_PROC
void myISR() {
clearFlagThatCausedInterrupt();
doSomeStuff();
}
Now find the *.prm file for the project and add a line at the end like this:
VECTOR 13 myISR /* Serial receive vector */
alternatively you can do this:
VECTOR ADDRESS 0xFFFD myISR
The vector number is the nth vector counting backwards from FFFE:FFFF, starting from 0.
FFFE:FFFF = vector 0
FFFC:FFFD = vector 1
etc.
You can ignore the vector.s table.
The #pragma TRAP_PROC tells the compiler to end the function with an RTI instruction instead of an RTS.
The VECTOR 13 myISR will write the address of the function, myISR() into the 13th vector. That's all that needs to happen for it to work, provided that the interrupt source is configured correctly.
Message Edited by rhinoceroshead on 2006-07-26 03:47 PM