Reputation: 13
I am using the following code, which main theme is to generate a pin interrupt in lpc 1837, I am facing trouble in getting interrupt, Anybody give suggestion what went wrong in this code Compiler: Keil
/* Configure pin as digital input using GPIO in pin multiplexing */
GPIO_SetDir(6,0,GPIO_DIR_INPUT);
GPIO_SetDir(6,2,GPIO_DIR_INPUT);
SCU_PinConfigure(0xC,1,( SCU_CFG_MODE_FUNC4 | SCU_SFS_EPUN | SCU_SFS_ZIF ));
SCU_PinConfigure(0xC,3,( SCU_CFG_MODE_FUNC4 | SCU_SFS_EPUN | SCU_SFS_ZIF ));
/* enable edge interrupt */
LPC_GPIO_PIN_INT->ISEL = 0x00UL;
/* enable rising edge interrupt */
LPC_GPIO_PIN_INT->IENR = (GPIO_PIN_INT_IENR_ENRL0_Msk |
GPIO_PIN_INT_IENR_ENRL1_Msk );
LPC_GPIO_PIN_INT->SIENR = (GPIO_PIN_INT_SIENR_SETENRL0_Msk |
GPIO_PIN_INT_SIENR_SETENRL1_Msk );
/* enable falling edge interrupt */
LPC_GPIO_PIN_INT->IENF = (GPIO_PIN_INT_IENF_ENAF0_Msk |
GPIO_PIN_INT_IENF_ENAF0_Msk);
LPC_GPIO_PIN_INT->SIENF = (GPIO_PIN_INT_SIENF_SETENAF0_Msk |
GPIO_PIN_INT_SIENF_SETENAF1_Msk );
/* Clear pending interrupt of pin interrupt 1*/
NVIC->ICPR[(((uint32_t)(int32_t)(0x21)) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)(0x21)) & 0x1FUL));
/* set priority for pin interrupt 1 */
NVIC_SetPriority(0x21, 1);
/* enable pin interrupt */
NVIC->ISER[(((uint32_t)(int32_t)(0x21)) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)(0x21)) & 0x1FUL));
Upvotes: 0
Views: 266
Reputation: 13
After all the mess, there is a input buffer SCU_PinConfigure(0xC,1,( SCU_CFG_MODE_FUNC4 | SCU_SFS_EPUN | SCU_SFS_ZIF | SCU_SFS_EZI ));
There is a bit which is used to Enable the Input buffers. After Enabling this bit, the input read and interrupts are enabled. Thanks for the Reply, May this answer will help for solving the Gpio inputs read and enabling the interrupts.
Upvotes: 1
Reputation: 1
I think I had the same problem as you several months ago. I set the GPIO in input-interrupt mode, but I couldn't set the ISR. I suggest you check your code by following steps:
If both of two steps are right, it proves that GPIO is in input-interrupt mode. If it can't get the ISR, find out where it goes. There must be some problems that occur in the process of hardware interrupt. The process is written by assembly language.
Upvotes: 0