LPC824: Stuck when "NVIC_EnableIRQ(PININT0_IRQn)"

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

LPC824: Stuck when "NVIC_EnableIRQ(PININT0_IRQn)"

ソリューションへジャンプ
2,203件の閲覧回数
robin_maeder
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

ラベル(1)
0 件の賞賛
返信
1 解決策
2,146件の閲覧回数
ZhangJennie
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

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
2,192件の閲覧回数
ZhangJennie
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 件の賞賛
返信
2,188件の閲覧回数
robin_maeder
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 件の賞賛
返信
2,180件の閲覧回数
ZhangJennie
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 件の賞賛
返信
2,157件の閲覧回数
robin_maeder
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 件の賞賛
返信
2,147件の閲覧回数
ZhangJennie
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

0 件の賞賛
返信