LCP824 GPIO issue when PINT is initialized

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

LCP824 GPIO issue when PINT is initialized

Jump to solution
1,941 Views
gschelotto
Contributor V

Hi, I'm facing to a strange behavior using LPC824M201JHI33 and the SDK version 2.7.0 in my custom board. I'm able to toggle a status LED tied to PIO0_15 and set PIO0_13 as input port. So far so good but if I want to detect a falling edge interrupt on PIO0_13 I do as follows:

// Connect trigger sources to PINT
SYSCON_AttachSignal(SYSCON, kPINT_PinInt0, kSYSCON_GpioPort0Pin13ToPintsel);

// Initialize PINT
PINT_Init(PINT);

// Setup Pin Interrupt 0 for falling edge
PINT_PinInterruptConfig(PINT, kPINT_PinInt0, kPINT_PinIntEnableFallEdge, pint_intr_callback);

// Enable callbacks for PINT0 by Index
PINT_EnableCallbackByIndex(PINT, kPINT_PinInt0);

The problem is after initializing PINT (line 5) the PIO0_15 (LED output) stuck at 0V whatever the value written on this port.

Any ideas to solve this problem?

regards,
gaston

0 Kudos
1 Solution
1,883 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

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

View solution in original post

0 Kudos
3 Replies
1,884 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

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

0 Kudos
1,392 Views
carter_wang
Contributor I

 

Hi XiangJun,

Is it possible to add some codes inside of PINT interrupt handler?

Or only can add in the callback function?

 

PINT

0 Kudos
1,883 Views
gschelotto
Contributor V

Great, thank you! Now It works as expected. So it's a problem in this SDK version, right?

Gaston

0 Kudos