I work with bear metal on the KL25z and I have read the last weak documentation and forum posts
about external Interrupt on the KLZ.
My problem is that the interrupt is only working with the Clock setup to PortA and toggles then the
Interrupt over and over again but it isn't working with an external source.
But I want to get an Interrupt if an external signal is incoming but if I comment out the Line:
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;
I get the HardFault Stackframe at the declaration of PORTA_PCR17 :
Stack frame:
R0 = 0000031C
R1 = 40049000
R2 = E000E100
R3 = C0000000
R12 = 00000016
LR = 80008980
PC = 0000092E
PSR = 81000000
Misc
LR/EXC_RETURN= FFFFFFF9
My Code:
int main(int argc, char* argv[]) {
// Send a greeting to the trace device (skipped on Release).
trace_puts("Hello ARM World!");
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;
__asm volatile("cpsie i"); //Enable Global Interrupts
NVIC_SetPriority(PORTA_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL);
PORTA_PCR17 |= PORT_PCR_MUX(1) | PORT_PCR_PE_MASK |
PORT_PCR_PS_MASK | PORT_PCR_IRQC(0x08); // Interrupt on rising and falling edge
NVIC_EnableIRQ(PORTA_IRQn); //Enable interrupt on IRQN
while (1) {}
}
extern "C" void
PORTA_IRQHandler() {
trace_puts("1");
trace_puts("2");
}
I hope someone can tell me the problem, I have no clue what I do wrong, I read so many docs and
I'm now done with my knowledge....
Greedings,
Max