The interrupt handler isn't called when PIO_0_23 is assigned as a PINT

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

The interrupt handler isn't called when PIO_0_23 is assigned as a PINT

Jump to solution
1,204 Views
daisukefukuda_n
Contributor III

Dear Sir/Madam,

This is Daisuke FUKUDA with NEXTY Electronics Japan. Thank you for your support.

I'm developing a certain demo board with LPCxpresso11U68. I designed that PIO_0_23 was IRQ from an IC.

I'm checking whether the interrupt handler is called correctly when PIO_0_23 is asserted. I'm using periph_pinint in lpcopen_3_02_lpcxpresso_lpcxpresso_11u68.zip. However the interrupt handler isn't called when PIO_0_23 is assinged. Also, I found the interrupt handler was called corrently when PIO_0_1, PIO_0_2, PIO_1_5 and PIO_1_6 were assigned. I tried 3 lpcxpressos but the phenomenon is reproduced.

Of cource, I'm going to all of PIOs but it isn't called when PIO_0_23 may be assigned.

Below is my modified code. Only GPIO_PININT_PIN and GPIO_PININT_PORT were changed.

Are there anything incorrect to modify for me?

/*
 * @brief Pin Interrupt example
 *
 * @note
 * Copyright(C) NXP Semiconductors, 2013
 * All rights reserved.
 *
 * @par
 * Software that is described herein is for illustrative purposes only
 * which provides customers with programming information regarding the
 * LPC products.  This software is supplied "AS IS" without any warranties of
 * any kind, and NXP Semiconductors and its licensor disclaim any and
 * all warranties, express or implied, including all implied warranties of
 * merchantability, fitness for a particular purpose and non-infringement of
 * intellectual property rights.  NXP Semiconductors assumes no responsibility
 * or liability for the use of the software, conveys no license or rights under any
 * patent, copyright, mask work right, or any other intellectual property rights in
 * or to any products. NXP Semiconductors reserves the right to make changes
 * in the software without notification. NXP Semiconductors also makes no
 * representation or warranty that such application will be suitable for the
 * specified use without further testing or modification.
 *
 * @par
 * Permission to use, copy, modify, and distribute this software and its
 * documentation is hereby granted, under NXP Semiconductors' and its
 * licensor's relevant copyrights in the software, without fee, provided that it
 * is used in conjunction with NXP Semiconductors microcontrollers.  This
 * copyright, permission, and disclaimer notice must appear in all copies of
 * this code.
 */

#include "board.h"

/*****************************************************************************
 * Private types/enumerations/variables
 ****************************************************************************/

#if defined(BOARD_MANLEY_11U68)
/* GPIO pin for PININT interrupt */
#define GPIO_PININT_PIN     1 /* GPIO pin number mapped to PININT */
#define GPIO_PININT_PORT    0 /* GPIO port number mapped to PININT */
#define GPIO_PININT_INDEX   0 /* PININT index used for GPIO mapping */
#define PININT_IRQ_HANDLER  PIN_INT0_IRQHandler /* GPIO interrupt IRQ function name */
#define PININT_NVIC_NAME    PIN_INT0_IRQn /* GPIO interrupt NVIC interrupt name */

#elif defined(BOARD_NXP_LPCXPRESSO_11U68)
/* Mapped to PIO0_1, ISP_EN button on LPCXpresso board */
//#define GPIO_PININT_PIN     1 /* GPIO pin number mapped to PININT */
#define GPIO_PININT_PIN     23 /* GPIO pin number mapped to PININT */
//#define GPIO_PININT_PIN     5 /* GPIO pin number mapped to PININT */
#define GPIO_PININT_PORT    0 /* GPIO port number mapped to PININT */
//#define GPIO_PININT_PORT    1 /* GPIO port number mapped to PININT */
#define GPIO_PININT_INDEX   0 /* PININT index used for GPIO mapping */
#define PININT_IRQ_HANDLER  PIN_INT0_IRQHandler /* GPIO interrupt IRQ function name */
#define PININT_NVIC_NAME    PIN_INT0_IRQn /* GPIO interrupt NVIC interrupt name */

#else
#error "PININT not configured for this example"
#endif /* defined (BOARD_MANLEY_11U68) */

/*****************************************************************************
 * Public types/enumerations/variables
 ****************************************************************************/

/*****************************************************************************
 * Private functions
 ****************************************************************************/

/*****************************************************************************
 * Public functions
 ****************************************************************************/

/**
 * @brief Handle interrupt from GPIO pin or GPIO pin mapped to PININT
 * @return Nothing
 */
void PININT_IRQ_HANDLER(void)
{
 Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
 Board_LED_Toggle(0);
}

/**
 * @brief Main program body
 * @return Does not return
 */
int main(void)
{
 /* Generic Initialization */
 SystemCoreClockUpdate();

 /* Board_Init calls Chip_GPIO_Init and enables GPIO clock if needed,
    Chip_GPIO_Init is not called again */
 Board_Init();
 Board_LED_Set(0, false);

 /* We'll use an optional IOCON filter (0) with a divider of 64 for the
    input pin to be used for PININT */
// Chip_Clock_SetIOCONFiltClockDiv(0, 64);

#if defined(BOARD_MANLEY_11U68)
 /* Configure GPIO pin as input */
 Chip_GPIO_SetPinDIRInput(LPC_GPIO, GPIO_PININT_PORT, GPIO_PININT_PIN);

 /* Configure pin as GPIO with pullup and use optional IOCON divider
    0 with 3 filter clocks for input filtering */
 Chip_IOCON_PinMuxSet(LPC_IOCON, GPIO_PININT_PORT, GPIO_PININT_PIN,
       (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_CLKDIV(0) | IOCON_S_MODE(3)));

#elif defined(BOARD_NXP_LPCXPRESSO_11U68)
 /* Configure GPIO pin as input */
 Chip_GPIO_SetPinDIRInput(LPC_GPIO, GPIO_PININT_PORT, GPIO_PININT_PIN);

 /* Configure pin as GPIO with pullup and use optional IOCON divider
    0 with 3 filter clocks for input filtering */
 Chip_IOCON_PinMuxSet(LPC_IOCON, GPIO_PININT_PORT, GPIO_PININT_PIN,
       (IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_CLKDIV(0) | IOCON_S_MODE(3)));
#endif

 /* Enable PININT clock */
 Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_PINT);

 /* Configure interrupt channel for the GPIO pin in SysCon block */
 Chip_SYSCTL_SetPinInterrupt(GPIO_PININT_INDEX, GPIO_PININT_PORT, GPIO_PININT_PIN);

 /* Configure channel interrupt as edge sensitive and falling edge interrupt */
 Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
 Chip_PININT_SetPinModeEdge(LPC_PININT, PININTCH(GPIO_PININT_INDEX));
 Chip_PININT_EnableIntLow(LPC_PININT, PININTCH(GPIO_PININT_INDEX));

 /* Enable interrupt in the NVIC */
 NVIC_ClearPendingIRQ(PININT_NVIC_NAME);
 NVIC_EnableIRQ(PININT_NVIC_NAME);

 /* Go to sleep mode - LED will toggle on each wakeup event */
 while (1) {
  /* Go to sleep state - will wake up automatically on interrupt */
  Chip_PMU_SleepState(LPC_PMU);
 }

 return 0;
}

Best regards,

Fukuda

Labels (1)
0 Kudos
1 Solution
1,079 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Daisuke Fukuda,

Thanks to contact our technical support.

PIO_0_1 is standard digital I/O pin,  while PIO_0_23 is digital /analog multiplexing pin,

so we need to disable Analog function and enable digital function when using GPIO interrupt.

Just add the below code , it will work:

    Chip_IOCON_PinMuxSet(LPC_IOCON, GPIO_PININT_PORT, GPIO_PININT_PIN,
                         (0x80|IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_CLKDIV(0) | IOCON_S_MODE(3)));

Also you can have a look at the register of 6.5.2 Pin control registers for digital/analog I/O pins of User Manual:

pastedImage_9.png


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

0 Kudos
3 Replies
1,079 Views
daisukefukuda_n
Contributor III

Hi Ms. Alice,

This is Daisuke FUKDUA with NEXTY Electronics Japan. Thnak you for your prompt reply.

Once enabling digital IO in PIO_0_23, I was able to find the handler was called successfully.

Your answer is what I was looking for, thanks!!

Please close it.

Best regards,

Fukuda

0 Kudos
1,078 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi Fukuda,

OK , good to hear it work.

BR

Alice

0 Kudos
1,080 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Daisuke Fukuda,

Thanks to contact our technical support.

PIO_0_1 is standard digital I/O pin,  while PIO_0_23 is digital /analog multiplexing pin,

so we need to disable Analog function and enable digital function when using GPIO interrupt.

Just add the below code , it will work:

    Chip_IOCON_PinMuxSet(LPC_IOCON, GPIO_PININT_PORT, GPIO_PININT_PIN,
                         (0x80|IOCON_FUNC0 | IOCON_MODE_PULLUP | IOCON_CLKDIV(0) | IOCON_S_MODE(3)));

Also you can have a look at the register of 6.5.2 Pin control registers for digital/analog I/O pins of User Manual:

pastedImage_9.png


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos