I'd appreciate some help with debugging strategy for a large Arduino application.
MCU is an ATmega1284P on an own-design board. It's 4000+ lines of application code and multiple 3rd party libraries, so it's difficult to post anything relevant here. The interrupt is handling a MCP2515 CAN bus controller, and takes the incoming message and places it in a circular buffer.
When I create a trivial application with all the 3rd party libraries and exercise the hardware, everything works fine.
When I add (a lot of) application code, the interrupt stops working. When I say 'stops working', the ISR doesn't run despite the interrupt signal being correctly asserted by the MCP2515, as observed with my logic analyser. No other hardware or 3rd party library uses interrupts, or suspends them.
The only thing I can think of is a buffer-overrun or similar trashing the Arduino ISR despatch table**, but it is perfectly fine. The relevant entry still points to my ISR and I can even call the ISR directly thru the pointer in the table.
I've hacked some debug code into the Arduino source to return the function pointer and to return a variable that is updated when the interrupt handler runs.
I've also added some code in the Arduino interrupt handler that flip-flops an LED. This does not happen, nor is my variable changed, so I assume the Arduino interrupt handler is not firing.
But, a trashed despatch table could point anywhere and is likely to cause random crashes, which does not happen. Everything else works fine *except* this interrupt.
What is the 'missing link' between the interrupt signal being asserted and the ISR firing ? And how could an application code bug mess this up ?
Unfortunately, I don't know enough to be able read the chip's registers and determine whether they've been messed with. But then, I can't imagine how a code bug could do this.
** For those who don't know, the Arduino core despatches interrupts indirectly via a table, which is populated by the attachInterrupt() function, per the source here: (interrupt despatch at line 379): https://github.com/MCUdude/Might...