detachInterruptVector?

duff

Well-known member
I was wondering if there is any plans to implement detachInterruptVector routine?

Why I ask is if i claim a certain ISR ( attachInterruptVector(IRQ_NUMBER_t ira, void (*function)(void)); ) and I then want to pass it back ( detachInterruptVector(IRQ_NUMBER_t ira, void (*function)(void)); ) to whatever the core defaults too. I guess i can do this myself if not.
 
I found myself needing a detactInterruptVector - has a fix been found yet (in the 9 years since the last post!)? If not, what would be the steps to do it? I'd like to do this for the QTM timer on Teensy 4.1
 
Most things don't have default ISRs, you can use NVIC_DISABLE_IRQ() to make sure it won't be triggered any more.
 
How does that relate to handling multiple interrupt functions attached non-simultaneously to the timer? I'd like to attach one ISR "my_isr_1" using attachInterruptVector(QTIMER1,my_isr_1);, then at some later point replace that with "my_isr_2".

If a second call of attachInterruptVector overwrites the first one, then I could imagine the following would work (which I have actually confirmed is working). But maybe someone can explain what is going on under the hood.

Code:
attachInterruptVector(QTIMER1,my_isr_1);
// start timer by changing QTM registers
NVIC_ENABLE_IRQ(IRQ_QTIMER1);
...

NVIC_DISABLE_IRQ(QTIMER1);
// followed by changing QTM registers to stop timer
...

attachInterruptVector(QTIMER1,my_isr_2);
// restart timer by changing registers
NVIC_ENABLE_IRQ(IRQ_QTIMER1);
...
 
attachInterruptVector does indeed overwrite whatever function was already set.
Code:
static inline void attachInterruptVector(enum IRQ_NUMBER_t irq, void (*function)(void)) { _VectorsRam[irq + 16] = function; asm volatile("": : :"memory"); }

All possible ISRs are just elements in the _VectorsRam array.
 
Back
Top