「已注销」 2019-10-07 00:16 采纳率: 100%
浏览 519
已结题

51单片机外部中断自动重复了一次

51单片机外部中断自动重复了一次

#include <reg52.h>
#include <intrins.h>

#define uchar unsigned char
#define uint unsigned int

void delay(uint);
void breath();

uchar tr_1;

void main()
{
    EX0=1;
    IT0=1;
    EA=1;
    P0=0xfe;
    delay(4000);
    while(1)
    {
        tr_1=P0;
        P0=_crol_(P0,1);
        tr_1=P0;
        delay(4000);
    }
}

void breath()
{
    uint count_1;
    count_1=0;
    while(count_1<100)
    {
        P0=0xff;
        delay(100-count_1);
        P0=0x00;
        delay(count_1);
        count_1++;
    }
    while(count_1>0)
    {
        P0=0x00;
        delay(count_1);
        P0=0xff;
        delay(100-count_1);
        count_1--;
    }
    P0=tr_1;
}

void delay(uint t)
{
    uint count_1;
    while(t>0)
    {
        for(count_1=0;count_1<5;count_1++);
        t--;
    }
}

void led() interrupt 0
{
    uint count_1;
    count_1=0;
    while(count_1<1)
    {
        breath();
        count_1++;
    }
}

点击了外部中断按钮之后,应该只出现一次呼吸灯的亮和灭,可是实际上有时候是一次,有时候是两次。???求助

  • 写回答

2条回答

  • 关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月16日
  • 已采纳回答 5月28日

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效