LPC824: Stuck when "NVIC_EnableIRQ(PININT0_IRQn)"

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC824: Stuck when "NVIC_EnableIRQ(PININT0_IRQn)"

Jump to solution
160 Views
Contributor II

Hello everyone

I am trying to simply configure an interrupt to detect a rising or falling edge on a pin. But whenever I want to finally enable the interrupt the SW gets "stuck".

Here my code:

 

GPIOInit();

// Configure P0.10 as input
LPC_GPIO_PORT->CLR0 = 0x400; // Clear P0.10 to '00'
LPC_GPIO_PORT->DIR0 &= 0xFFFFFBFF; // Set P0.10 as input

// Configure P0.10 as pin interrupts 0 by writing to the PINTSELs in SYSCON
LPC_SYSCON->PINTSEL[0] = 10; // PINTSEL0 is P0.10

// Configure the Pin interrupt mode register (a.k.a ISEL) for edge-sensitive
LPC_PIN_INT->ISEL = 0x0;

// Configure the IENR (pin interrupt enable rising) for rising edges
LPC_PIN_INT->IENR = 0x1;

// Configure the IENF (pin interrupt enable falling) for falling edges
LPC_PIN_INT->IENF = 0x1;

// Clear any pending or left-over interrupt flags
LPC_PIN_INT->IST = 0xFF;

NVIC_SetPriority(PININT0_IRQn, 1);

// Enable pin interrupts 0 in the NVIC
NVIC_EnableIRQ(PININT0_IRQn);  // --> SW stucks here

 

Here is what NVIC_EnableIRQ does:

__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
{
NVIC->ISER[0] = (1 << ((uint32_t)(IRQn) & 0x1F));
}

 

The SW can not pass the last line. I am not exaclty sure what happens in this moment because I only flash the device with the hex file without the possibility for debugging. But no command after the last line will get executed. When I disable the last line all is running fine (apart from the interrupt of course). I have another interrupt (SPI0) activated with the same command (NVIC_EnableIRQ(SPI0_IRQn)) and this is working correctly.

I tried a lot of things but I could not find the problem.

I really appriciate your help.

Regards Robin

Labels (1)
0 Kudos
1 Solution
103 Views
NXP TechSupport
NXP TechSupport

Hi 

RESET_PeripheralReset(kGPIO0_RST_N_SHIFT_RSTn) is to reset GPIO0 module. it exists in SDK  PINT_Init() function by default. the SDK PINT demo is to showcase PINT usage only, reset GPIO0 module then configure PINT feature is ok.

If your code also use other pins of GPIO0, for example, toggle LED, as RESET_PeripheralReset(kGPIO0_RST_N_SHIFT_RSTn) reset, you need reinitialize the related pin.

Best Regards

Jun Zhang

View solution in original post

0 Kudos
5 Replies
149 Views
NXP TechSupport
NXP TechSupport

Hi

MCUXpresso SDK includes PINT demo code. 

In the example, The pint_pin_interrupt will output the pin interrupt event into serial terminal.

When start running this example, main routine will initialize clock, pin mux configuration,
and configure the PINT module to make it work in interrupt way. Users are prompted to
press the SW1(P0.4) or SW2(P0.12), board will output the pattern match event.

 

Please refer it to develop yours PINT code

0 Kudos
145 Views
Contributor II

Hi 

I wrote the code according to the example code provided here:

LPC824 Example Code Bundle LPCXpresso

https://www.nxp.com/webapp/sps/download/preDownload.jsp?render=true

 

What is the difference to the PINT demo you mentioned and which samples should be used?

0 Kudos
137 Views
NXP TechSupport
NXP TechSupport

Codebandle is old package. We don't recommend it to new users.

Our recommendation is MCUXpresso SDK. We keep maintaining it for new feature and bug fix.

0 Kudos
114 Views
Contributor II

I got it working with the SDK example. But with that I had the same problem as in this topic:

https://community.nxp.com/t5/LPC-Microcontrollers/LCP824-GPIO-issue-when-PINT-is-initialized/td-p/10...

I was searching hours for a solution. Why is there this command in the PINT_Init file: RESET_PeripheralReset(kGPIO0_RST_N_SHIFT_RSTn);

Regards Robin

0 Kudos
104 Views
NXP TechSupport
NXP TechSupport

Hi 

RESET_PeripheralReset(kGPIO0_RST_N_SHIFT_RSTn) is to reset GPIO0 module. it exists in SDK  PINT_Init() function by default. the SDK PINT demo is to showcase PINT usage only, reset GPIO0 module then configure PINT feature is ok.

If your code also use other pins of GPIO0, for example, toggle LED, as RESET_PeripheralReset(kGPIO0_RST_N_SHIFT_RSTn) reset, you need reinitialize the related pin.

Best Regards

Jun Zhang

View solution in original post

0 Kudos