> Hi! > > Has anyone ever changed an interrupt handler during runtime? > I need to do that and any idea is welcome. > > I suppose I should declare two ISR like: > > interrupt (NOVECTOR) ISR1 {....} > interrupt (NOVECTOR) ISR2 {....} > > and then write the address of the routine I want in the flash in the > vector table. > > Or maybe is it better something like: > > interrupt (TIMERA0) ISR { > if (flag) > func1(); > else > func2(); > } > > I would prefer the first solution because I have some performance > issues with the second one. > > Any comment ? > thanks, > > R# >
There shouldn't be any real problem with re-writing the flash page, but there are a number of things you have to be careful of - make sure all interrupts are turned off before re-writing the page, including any possible NMI sources. There is also the question of reliability - what happens if there is a power failure during the update? As long as you are careful, however, it should work - though it is not a good solution if you are swapping vectors often. If you have performance issues with the more standard flag-based solution, try using inlining for the two functions. That should avoid any unnecessary register save/restores, which might improve matters.