Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Embedded 皮层M-0:简单外部中断_Embedded_Arm_Interrupt_Microcontroller_Cortex M - Fatal编程技术网

Embedded 皮层M-0:简单外部中断

Embedded 皮层M-0:简单外部中断,embedded,arm,interrupt,microcontroller,cortex-m,Embedded,Arm,Interrupt,Microcontroller,Cortex M,我正在尝试在LPC812 uC上设置外部中断。我编写了以下代码 #include "LPC8xx.h" #define RLED 7 // red LED bool pause = false; void PININT0_IRQHandler(void) { pause = !pause; } int main(void) { LPC_GPIO_PORT->DIR0 |= 1<<RLED; // set pin as output LPC_GPIO_PORT-

我正在尝试在LPC812 uC上设置外部中断。我编写了以下代码

#include "LPC8xx.h"

#define RLED 7  // red LED

bool pause = false;

void PININT0_IRQHandler(void)
{
  pause = !pause;
}

int main(void) {

LPC_GPIO_PORT->DIR0 |= 1<<RLED; // set pin as output

LPC_GPIO_PORT->SET0 = 1<<RLED;

NVIC_EnableIRQ(PININT0_IRQn);

while (1)
{
    if(!pause)
    {
          LPC_GPIO_PORT->CLR0 = 1<<RLED;
    }
}

}
#包括“LPC8xx.h”
#定义RLED 7//红色LED
布尔暂停=假;
void PININT0_IRQHandler(void)
{
暂停=!暂停;
}
内部主(空){

LPC_GPIO_PORT->DIR0 |=1我不熟悉NXP MCU。 但至少要将break piont放在pinint0u IRQHandler中,以清楚地理解中断是不会生成的

另外,清除处理程序内部的中断标志也很好

除NVIC设置外,一些外围设备还需要外围寄存器中的中断权限

你在什么地方设置了输入pin码吗


您的代码只将GPIO 7引脚初始化为输出。

我没有看到任何代码将处理程序地址加载到向量表中?@MartinJames它是必须的吗?在文件cr_startup_lpc8xx.cpp中有函数void PININT0_IRQHandler(void)的声明设置为IntDefaultHandler的别名。这是否意味着,当我像以前那样定义函数时,它就可以工作了?或者我真的应该将地址加载到向量表中吗?如果是,正确的方法是什么?您是否设置了引脚中断时钟和GPIO时钟?在启动器P0中分配了引脚?请通读用户手册的第8章。@Hipoli您在中断处理程序中设置了断点吗?当您说“它不工作”时您必须更具体地说明发生了什么以及预期的行为。您还应该向无限循环中添加代码,以便在pause=true时打开GPIO。欢迎这样做。这将更好地作为一个注释,因为您需要更多信息。感谢您的回复。我知道,我应该清除标志,但这只是为了了解,如何正确设置中断。据我所知,PIN0是默认输入