Installing interrupts with KSDK 2.0?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Installing interrupts with KSDK 2.0?

跳至解决方案
1,467 次查看
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.

标记 (2)
0 项奖励
回复
1 解答
1,248 次查看
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.

在原帖中查看解决方案

1 回复
1,249 次查看
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.