Changing an interrupt vector

I want to change the interrupt vector on timer 1, TIMER1_COMPA_vect, to point into one of 16 different functions to call. The function called will depend on a variable who's value is changed by button pushes.

Yes I know I could just use a case statement to pick out the right one in a:-

ISR(TIMER1_COMPA_vect) { ..... }

ISR,
but time is of the essence here and I would like to do it in as few a clock cycles as possible.

Any one know of the syntax I need to change this interrupt vector to the appropriate function? I am assuming it is a matter of changing the vector to the address of my function.

Yes I will disable interrupts when changing the vector.

Thanks.

Any one know of the syntax I need to change this interrupt vector to the appropriate function? I am assuming it is a matter of changing the vector to the address of my function.

The interrupt vector table is stored in flash (either at the start of the flash or at the start of the boot loader section). As far as I know you cannot move the table to the RAM. So you probably end up having one interrupt handler and using a jump table there.

pylon: So you probably end up having one interrupt handler and using a jump table there.

Right.

void dummy();
void isr1();
void isr2();
void isr3();

void (*jumpTable[])() = {dummy, isr1, isr2, isr3};
volatile uint8_t isrSelect = 0;

void setup() {
}

void loop() {
}

ISR(TIMER1_COMPA_vect) {
  jumpTable[isrSelect]();
}

void dummy() {
}

void isr1() {
  // Do Stuff
}

void isr2() {
  // Do Differnt Stuff
}

void isr3() {
  // Do Differnt Different Stuff
}

I think you’re missing a pair of these () in the ISR

TheMemberFormerlyKnownAsAWOL:
I think you're missing a pair of these () in the ISR

Fixed. Thanks.

Many thanks guys, I will give it a try and report back.

Thanks that worked a treat.
Here is the documentation on what I was working on:- GitHub - Grumpy-Mike/GlitchStorm: My take on the Glitch Storm synth
And this is the video:-
Glitch Storm - YouTube

Taken from the post on:- glitch storm synth and applications in child psychology