简体   繁体   English

LPC 1837中的GPIO引脚中断问题

[英]ISSUE IN GPIO PIN INTERRUPT in LPC 1837

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 我正在使用以下代码,其主要主题是在lpc 1837中生成一个pin中断,我在获取中断时遇到了麻烦,有人建议该代码出了什么问题编译器: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));

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 )); 混乱之后,有一个输入缓冲区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. 感谢您的答复,愿这个答案将有助于解决读取的Gpio输入并启用中断。

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. 我将GPIO设置为输入中断模式,但无法设置ISR。 I suggest you check your code by following steps: 我建议您按照以下步骤检查代码:

  1. check the interrupt source signal. 检查中断源信号。 Make sure it works. 确保它可以工作。
  2. print the important variate and register to observe whether it is right. 打印重要变量并注册以观察其是否正确。

If both of two steps are right, it proves that GPIO is in input-interrupt mode. 如果两个步骤都正确,则表明GPIO处于输入中断模式。 If it can't get the ISR, find out where it goes. 如果无法获得ISR,请找出其去向。 There must be some problems that occur in the process of hardware interrupt. 硬件中断过程中肯定会出现一些问题。 The process is written by assembly language. 该过程由汇编语言编写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM