Hi, Gaston,
Pls refer to the code void PINT_Init(PINT_Type *base). In the function, there is line:
RESET_PeripheralReset(kGPIO0_RST_N_SHIFT_RSTn);
The above line resets the GPIO port, after resetting the GPIO module, all the GPIO configuration is invalid, so you have to reinitialize the GPIO module or delete the line.
void PINT_Init(PINT_Type *base)
{
uint32_t i;
uint32_t pmcfg;
assert(base);
pmcfg = 0;
for (i = 0; i < FSL_FEATURE_PINT_NUMBER_OF_CONNECTED_OUTPUTS; i++)
{
s_pintCallback[i] = NULL;
}
/* Disable all bit slices */
for (i = 0; i < PINT_PIN_INT_COUNT; i++)
{
pmcfg = pmcfg | (kPINT_PatternMatchNever << (PININT_BITSLICE_CFG_START + (i * 3U)));
}
#if defined(FSL_FEATURE_CLOCK_HAS_GPIOINT_CLOCK_SOURCE) && (FSL_FEATURE_CLOCK_HAS_GPIOINT_CLOCK_SOURCE == 1)
/* Enable the peripheral clock */
CLOCK_EnableClock(kCLOCK_GpioInt);
/* Reset the peripheral */
RESET_PeripheralReset(kGPIOINT_RST_N_SHIFT_RSTn);
#elif defined(FSL_FEATURE_CLOCK_HAS_GPIOINT_CLOCK_SOURCE) && (FSL_FEATURE_CLOCK_HAS_GPIOINT_CLOCK_SOURCE == 0)
/* Enable the peripheral clock */
CLOCK_EnableClock(kCLOCK_Gpio0);
/* Reset the peripheral */
RESET_PeripheralReset(kGPIO0_RST_N_SHIFT_RSTn);
#else
/* Enable the peripheral clock */
CLOCK_EnableClock(kCLOCK_Pint);
/* Reset the peripheral */
RESET_PeripheralReset(kPINT_RST_SHIFT_RSTn);
#endif /* FSL_FEATURE_CLOCK_HAS_GPIOINT_CLOCK_SOURCE && FSL_FEATURE_CLOCK_HAS_NO_GPIOINT_CLOCK_SOURCE*/
/* Disable all pattern match bit slices */
base->PMCFG = pmcfg;
}
I have debug it. I use the code, it works fine.
#include "fsl_debug_console.h"
#include "board.h"
#if defined(FSL_FEATURE_SYSCON_HAS_PINT_SEL_REGISTER) && FSL_FEATURE_SYSCON_HAS_PINT_SEL_REGISTER
#include "fsl_syscon.h"
#else
#include "fsl_inputmux.h"
#endif /* FSL_FEATURE_SYSCON_HAS_PINT_SEL_REGISTER */
#include "fsl_pint.h"
#include "pin_mux.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define DEMO_PINT_PIN_INT0_SRC kSYSCON_GpioPort0Pin4ToPintsel
#define DEMO_PINT_PIN_INT1_SRC kSYSCON_GpioPort0Pin12ToPintsel
#define DEMO_PINT_PIN_INT2_SRC kSYSCON_GpioPort0Pin0ToPintsel
/*******************************************************************************
* Prototypes
******************************************************************************/
/*******************************************************************************
* Variables
******************************************************************************/
/*******************************************************************************
* Code
******************************************************************************/
/*!
* @brief Call back for PINT Pin interrupt 0-7.
*/
void PIO0_15Init(void);
void pint_intr_callback(pint_pin_int_t pintr, uint32_t pmatch_status)
{
PRINTF("\f\r\nPINT Pin Interrupt %d event detected.", pintr);
GPIO->NOT[0]=1<<15;
}
/*!
* @brief Main function
*/
int main(void)
{
/* Board pin, clock, debug console init */
/* Enable clock of uart0. */
CLOCK_EnableClock(kCLOCK_Uart0);
/* Ser DIV of uart0. */
CLOCK_SetClkDivider(kCLOCK_DivUsartClk, 1U);
PIO0_15Init();
BOARD_InitPins();
BOARD_BootClockIRC12M();
BOARD_InitDebugConsole();
/* Clear screen*/
PRINTF("%c[2J", 27);
/* Set cursor location at [0,0] */
PRINTF("%c[0;0H", 27);
PRINTF("\f\r\nPINT Pin interrupt example\r\n");
#if defined(FSL_FEATURE_SYSCON_HAS_PINT_SEL_REGISTER) && FSL_FEATURE_SYSCON_HAS_PINT_SEL_REGISTER
/* Connect trigger sources to PINT */
SYSCON_AttachSignal(SYSCON, kPINT_PinInt0, DEMO_PINT_PIN_INT0_SRC);
SYSCON_AttachSignal(SYSCON, kPINT_PinInt1, DEMO_PINT_PIN_INT1_SRC);
#else
/* Connect trigger sources to PINT */
INPUTMUX_Init(INPUTMUX);
INPUTMUX_AttachSignal(INPUTMUX, kPINT_PinInt0, DEMO_PINT_PIN_INT0_SRC);
INPUTMUX_AttachSignal(INPUTMUX, kPINT_PinInt1, DEMO_PINT_PIN_INT1_SRC);
INPUTMUX_AttachSignal(INPUTMUX, kPINT_PinInt2, DEMO_PINT_PIN_INT2_SRC);
/* Turnoff clock to inputmux to save power. Clock is only needed to make changes */
INPUTMUX_Deinit(INPUTMUX);
#endif /* FSL_FEATURE_SYSCON_HAS_PINT_SEL_REGISTER */
/* Initialize PINT */
PINT_Init(PINT);
PIO0_15Init();
/* Setup Pin Interrupt 0 for rising edge */
PINT_PinInterruptConfig(PINT, kPINT_PinInt0, kPINT_PinIntEnableRiseEdge, pint_intr_callback);
/* Setup Pin Interrupt 1 for falling edge */
PINT_PinInterruptConfig(PINT, kPINT_PinInt1, kPINT_PinIntEnableFallEdge, pint_intr_callback);
/* Setup Pin Interrupt 2 for both rising and falling edge */
PINT_PinInterruptConfig(PINT, kPINT_PinInt2, kPINT_PinIntEnableBothEdges, pint_intr_callback);
/* Enable callbacks for PINT */
PINT_EnableCallback(PINT);
PRINTF("\r\nPINT Pin Interrupt events are configured\r\n");
PRINTF("\r\nPress corresponding switches to generate events\r\n");
while (1)
{
__WFI();
}
}
void PIO0_15Init(void)
{
//enable gated clock
SYSCON->SYSAHBCLKCTRL|=1<<6|1<<18;
//set the GPIO direction
GPIO->DIR[0]|=1<<15;
//toggle GPIO
GPIO->NOT[0]=1<<15;
GPIO->NOT[0]=1<<15;
GPIO->NOT[0]=1<<15;
GPIO->NOT[0]=1<<15;
GPIO->NOT[0]=1<<15;
}
BR
XiangJun Rong