Continuing the discussion from Solid green/lockup after ~44 minutes:
I had a working application that used a timer, but when I went to turn my timer code into a C++ class, the app would freeze after a certain amount of time. Using the timer more frequently decreased the time before the lockup.
I started over and incrementally ended up with working code, the only difference I saw was moving attachSystemInterrupt(hal_irq_t irq, wiring_interrupt_handler_t handler)
into the initialization instead of the timer start. Initially I was using a different callback depending on what mode my timer class was in. Looking at that code, it appears to allocate callback.data = new wiring_interrupt_handler_t(h);
, but ignores the previous callback returned from HAL_Set_System_Interrupt_Handler
.
I suspect this is a memory leak, and when allocation eventually failed explained why my app froze, the interrupt eventually called into nowhere. Is this correct?
As a workaround, I can set one handler, and dispatch from that depending on the mode of my timer.