You can set up multiple capture and compare registers (CCR) for the timer A1. Each application could use its own. Then in the handler demultiplex by looking at TAIV
. From TI sample code for msp430f1611:
void __attribute__ ((interrupt(TIMERA1_VECTOR))) Timer_A1 (void)
{
switch( TAIV )
{
case 2: CCR1 += 1000; // Add Offset to CCR1
break;
case 4: CCR2 += 10000; // Add Offset to CCR2
break;
case 10: P1OUT ^= 0x01; // Timer_A1 overflow
break;
}
}
This MCU has three registers: CCR0, CCR1, and CCR2. Timer A1 interrupt handler is called for CCR1, CCR2, and on overflow of the timer counter (TAR
). CCR0 is handled by a separate interrupt handler (A0).
Don't try to overwrite the interrupt vector during runtime - that's a terrible idea. On msp430 it also requires reprogramming (part of) the flash. Instead, write a single handler and differentiate the application-specific logic inside it.