Installing interrupts with KSDK 2.0?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Installing interrupts with KSDK 2.0?

Jump to solution
1,117 Views
robertgbaruch
Contributor II

This is sort of resurrecting the thread I started a while back. In that thread, I was having a problem with installing an interrupt routine. The way I solved it was to add -Xlinker --defsym=__ram_vector_table__=1 to the linker options, and then use InstallIRQHandler to explicitly install the IRQ handler.

Now, the other solution was to simply define the IRQ handler and it would override the weak one defined elsewhere.

However, I've dusted off that example, and it does not work! It's very nearly a copy of the PIT example included with the SDK.

volatile bool pitIsrFlag = false;

void PIT0_IRQHandler(void)
{
 /* Clear interrupt flag.*/
 PIT_ClearStatusFlags(PIT, kPIT_Chnl_0, kPIT_TimerFlag);
 pitIsrFlag = true;
}‍‍‍‍‍‍‍‍

First, when running the code and the timer goes off, I get stuck in IntDefaultHandler. This shows that the IRQ handler was definitely not installed properly. I've checked the map file, and it shows two instances of PIT0_IRQHandler, one from my main file, and one from startup_mk64f12.o.

Tags (2)
0 Kudos
Reply
1 Solution
898 Views
robertgbaruch
Contributor II

Solution found! According to Startup Code and Interrupt Handlers, the handler must be inside an extern "C" block if you're compiling under C++. Otherwise the name gets mangled and will not match the weak symbol.

View solution in original post

1 Reply
899 Views
robertgbaruch
Contributor II

Solution found! According to Startup Code and Interrupt Handlers, the handler must be inside an extern "C" block if you're compiling under C++. Otherwise the name gets mangled and will not match the weak symbol.