T4.1, attachInterruptVector() and NVIC Controller

tomryan

Member
Hello, I posted in the technical support board already with the specific issue I'm having, but what I could really use is some general advice on the attachInterruptVector() fx and the Nested Vectored Interrupt Controller.

Can you attach an ISR fx to an IRQ_vec, and then de-attach that ISR and attach a different one? Because interrupt vectors aren't simply bit-addressable (or at least I didn't see their addresses), I don't think it's as easy as just swapping out the function pointer.

I've been going off of Paul Stoffregen's github repo (thank you) with imxrt.h for Teensy 4 IRQ vectors and interrupt.c which shows how attachInterrupt() is implemented:

https://github.com/PaulStoffregen/cores/blob/master/teensy4/interrupt.c

https://github.com/PaulStoffregen/cores/blob/master/teensy4/imxrt.h

I see that attachInterruptVector() operates on a _VectorsRam[] of function pointers, but I don't know what I'm missing. Thank you, any help is appreciated!

*Note* If interested here is a link to the specific problem I'm trying to solve in the Technical Support Board: https://forum.pjrc.com/threads/70640-trouble-attaching-consecutive-ISRs-to-the-same-FLEXPWM-IRQ
 
Can you attach an ISR fx to an IRQ_vec, and then de-attach that ISR and attach a different one? Because interrupt vectors aren't simply bit-addressable (or at least I didn't see their addresses), I don't think it's as easy as just swapping out the function pointer.

Generally, yes, you can change interrupt functions. Seems like it should probably be done like this

- set function pointer
- enable interrupt
...
- disable interrupt
- set new function pointer
- enable interrupt
 
Back
Top