FRDM KL27Z Interrups handlers not being overwritten

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

FRDM KL27Z Interrups handlers not being overwritten

Jump to solution
884 Views
donperotti2
Contributor I

Greetings, I recently bought a FRDM-KL27Z board and was trying some basic things with it, the latest attempt setting the TPM to output compare, and getting it to interrupt on said compare.

I created a new project, added the TPM drivers, initialize everything on the config tools (i'm not trying to alter the state of the channel pins just generate an interrupt on compare) copied the interrupt handler template and pasted it above my main and... it doesn't work.

3.png


When i pause the debugging session the program is stuck at the default handler, and setting a breakpoint here:

1.png

and pressing F5 to step into it takes me to the default interrupt handler:

2.png

What drives me mad is that this is exactly what the demo for the adc16 shows on handling interrupts (regardless of wich vector it is):

4.png

what am I missing, why does it fail on my code but not on the example?

I'll attach a zip of the project that i generated with the export tool from MCUxpresso.

0 Kudos
1 Solution
845 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

This is a common question when c/c++ mix. Use extern "C". Please see this link.

https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863141

 

Regards,

Jing

View solution in original post

0 Kudos
4 Replies
877 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Santiago,

Please check in startup_mkl227z644.c. The interrupt vector table is g_pfnVectors. In this table, TPM2's interrupt service routine is TPM2_IRQHandler. The Config Tool will not touch this part. You much keep your code name same with the item in vector table.

 

Regards,

Jing 

0 Kudos
862 Views
donperotti2
Contributor I

Hi, I had already checked the table, the config tool doesn't change the table but comes with this button:
b.png

I copied that and pasted it over my main, which is, again, exactly what the example for the adc16interrupt does, but just to check, I went and did as you instructed:

a.png

all the code remains the same I've simply renamed: TPM2_IRQHANDLER to TPM2_IRQHandler, not that it should matter becouse when i go to peripherals.h:

c.png

That all caps name is just a define to the same vector, again, what am I missing? why does the example compile and work but my code doesn't?

0 Kudos
846 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

This is a common question when c/c++ mix. Use extern "C". Please see this link.

https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-working-under-C-but-not-C/m-p/863141

 

Regards,

Jing

0 Kudos
837 Views
donperotti2
Contributor I

Yeah using extern "C" before the function name solved it.

I'll leave some info on why you have to use extern C:

https://stackoverflow.com/questions/1041866/what-is-the-effect-of-extern-c-in-c

0 Kudos