Using PTA4 as an input in K64F only fires interrupt once

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Using PTA4 as an input in K64F only fires interrupt once

882件の閲覧回数
muriukidavid
Contributor II

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.

ラベル(1)
タグ(1)
0 件の賞賛
2 返答(返信)

645件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, David,

I have downloaded the SDK package of FRDM-K64F based on MCUExpresso tools from the link:

www.nxp.com/ksdk

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.

void BOARD_SW_IRQ_HANDLER(void)
{
    /* 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)
    __DSB();
#endif
}

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

BR

Xiangjun rong

0 件の賞賛

645件の閲覧回数
muriukidavid
Contributor II

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.

0 件の賞賛