This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于cc2530中断问题求助

我写了个测试按键中断的:

mian函数中led2是闪烁的,当按键按下时产生下降沿中断 led1亮

然而 按下之后led1确实亮 但led2的闪烁频率变得很慢了(附视频)

#pragma vector = P0INT_VECTOR
__interrupt void P0_ISR(void)
{
if(P0IFG&(1<<4))
{
//#KEY1触发

LED2=0;
P0IFG = 0;

}
}

void main()
{

LED_init();
Key_init();


while(1){
delay(100);
LED1=0;
delay(100);
LED1=1;
}}

  • 您可以使用单步调试看一下

  • 在P0端口中设置P0_4和P0_5引脚中断使能

    当这两个引脚触发中断时,以下这段中断处理函数的执行顺序是怎样的

    #pragma vector = P0INT_VECTOR
    __interrupt void P0_ISR(void)
    {
    if(P0IFG&(1<<4))
    {


    LED2=0;
    P0IFG = 0;

    }
    if(P0IFG&(1<<5))
    {


    LED2=1;
    P0IFG = 0;
    return;

    }}

    如果是P0_4引发中断 

    在处理完if(P0IFG&(1<<4))
    {


    LED2=0;
    P0IFG = 0;

    }这段时 会不会接之往下执行代码 还是在中断标志位P0IFG = 0;时就终止了该段函数的执行