I want to use the switch SW3 connected to PTA4 in the FRDM-K64F board. I configured the pin as a GPIO and enabled interrupts. I also disabled the NMI function in the flash configuration field as suggested in answers to other similar questions. I am using MCUXpresso IDE and KSDK. I have attached my project here. I have two ADC inputs triggered using PDB, although I doubt that causes the problem. I can debug the code up until the first interrupt happens, but after clearing interrupts, no more interrupts happen from PTA4. The other switch, PTC6 works OK with exactly the same interrupts code.
Can anyone kindly help me figure out why this is happening. Meanwhile, I will try to create a baremetal project with only this switch and see.
I have downloaded the SDK package of FRDM-K64F based on MCUExpresso tools from the link:
I have tested the example frdmk64f_gpio_input_interrupt, after I press SW3 on FRDM-K64F board, the void BOARD_SW_IRQ_HANDLER(void) can be entered multiple times. Pls have a test yourself and check the register setting.
/* Clear external interrupt flag. */
GPIO_PortClearInterruptFlags(BOARD_SW_GPIO, 1U << BOARD_SW_GPIO_PIN);
/* Change state of button. */
g_ButtonPress = true;
/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
exception return operation might vector to incorrect interrupt */
#if defined __CORTEX_M && (__CORTEX_M == 4U)
BOARD_SW_GPIO_PIN is 4.
BTW, the PORTA_PCR4 register is 0xA0143, pls chcek the register in debugger in your code.
The PTA4 is multiplexed with NMI pin, pls pay attention the NMI pin setting.
Hope it can help you
I compared my project with the example you pointed me to and I figured out what was wrong. For some strange reason, I had the internal pull up resistor disabled and low drive strength on the pin. I never bothered to check those settings because I thought I configured both switches the same.
You actually dont need to disable the NMI function in the flash configuration fields, as long as the GPIO Pin is configured as alt function 1 it works well.
Also, the errata 838869 code doesn't do anything. I left it in there just in case.
Thanks for pointing me to the KSDK example.