Hi
I need to use the attachInterruptVector() to be able to capture a digital signal with a max. freq of 10 MHz with the superfast Teensy 4.0. The normally used (and easy to use) attachInterrupt has a too big delay between the signal change and the start of the interrupt routine.
After reading and searching in this forum, I realized why the attachInterrupt() is slower and that I need to use the attachInterruptVector(). I also once had to make that with an Arduino / ATmega32u4, but the Teensy 4.0 / IMXRT1060RM is at a completely different level...
I've found a post with a similar topic and tried to adapt it to my project (see last post): https://forum.pjrc.com/threads/57717-port-and-toggle-question-T4
That is my code, but sadly it doesn't work:
It compiles perfectly, but no interrupt occurs. Tested at 600 MHz/Fast settings. For sure I did something wrong...
Can you please help me?
Thanks,
Stephan
I need to use the attachInterruptVector() to be able to capture a digital signal with a max. freq of 10 MHz with the superfast Teensy 4.0. The normally used (and easy to use) attachInterrupt has a too big delay between the signal change and the start of the interrupt routine.
After reading and searching in this forum, I realized why the attachInterrupt() is slower and that I need to use the attachInterruptVector(). I also once had to make that with an Arduino / ATmega32u4, but the Teensy 4.0 / IMXRT1060RM is at a completely different level...
I've found a post with a similar topic and tried to adapt it to my project (see last post): https://forum.pjrc.com/threads/57717-port-and-toggle-question-T4
That is my code, but sadly it doesn't work:
Code:
void change() {
//do something extremely fast
GPIO9_ISR = 0x08; // clear the IRQ
asm("dsb");
}
void setup() {
pinMode(2, INPUT); // connected to EMC_04
pinMode(5, INPUT); // connected to EMC_08
attachInterruptVector(IRQ_GPIO6789, &change);
NVIC_ENABLE_IRQ(IRQ_GPIO6789);
GPIO9_GDIR &= ~0x08;
GPIO9_EDGE_SEL = 0x08;
GPIO9_ISR = 0xffff;
//attachInterrupt(digitalPinToInterrupt(2), change, CHANGE); // works, but "slow"
//attachInterrupt(digitalPinToInterrupt(5), change, CHANGE); // works, but "slow"
}
void loop() {
// do something else
}
It compiles perfectly, but no interrupt occurs. Tested at 600 MHz/Fast settings. For sure I did something wrong...
Can you please help me?
Thanks,
Stephan