cc_sky 发表于 2011-12-1 14:48:27

51系列单片机的按键中断控制程序 求帮助!!!

在做一个51系列最小系统,主要功能是控制数码管循环显示“0~9”,外加一个中断控制按键暂停,暂停键按下后,LED灯亮。
做完上电之后发现,数码管能循环显示 0~9,中断控制的暂停没有用。但同样是中断控制的LED灯能被点亮,不过被点亮得没有规律,有时按一下,亮一次,有时候按几下才熄灭。很奇怪,我感觉是程序的问题。麻烦大家帮忙看看
这是程序:
# include <reg51.h>
# include <intrins.h>
# define uchar unsigned char
# define unit unsigned int
sbit LED1 = P1^0;
uchar code DSY_CODE[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xff};
unit Count_A = 0;
void DELAYMS(unit x)
{
   uchar t;
   while(x--) for(t = 0;t < 220;t++);
}
void External_Interrupt_0() interrupt 0
{
    Count_A = ~ Count_A;
    LED1 = ~ LED1;
   }
void main()
{
uchar i = 0;
IT0 = 1 ;
IE = 0x81;
IP = 0x01 ;
P0 = 0xff;
LED1 = 1;
while(1)
{
    loop:
    Count_A = Count_A;
    if(Count_A==1)
      goto loop;
    P0 = DSY_CODE;
    i = (i+1)%10;
    DELAYMS(280);
   }
}
原理图:

http://cache.amobbs.com/bbs_upload782111/files_48/ourdev_700512OEPWZH.jpg
(原文件名:~5V@4K0F_K3PA@I(RP{QKTY.jpg)

cc_sky 发表于 2011-12-2 08:58:08

各位帮个忙啊~

yihui184 发表于 2012-8-30 00:01:17

cc_sky 发表于 2011-12-2 08:58 static/image/common/back.gif
各位帮个忙啊~

后面解决啦没有啊?感觉你程序非常有问题。
页: [1]
查看完整版本: 51系列单片机的按键中断控制程序 求帮助!!!