suicake
驱动牛犊
驱动牛犊
  • 注册日期2005-07-21
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望3点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:672回复:0

新手∶用c写了一计数的程序在实验板上,但是出了点小问题,不知该如何解决

楼主#
更多 发布于:2005-07-25 12:32
  #include "reg52.h"

char code LEDCODE[]={0x3f,0x6,0x5b,0x4f,0x66,0x6d,0x7d,0x7,0x7f,0x6f};
unsigned char Disbuff[6] , Ledp=0;
sbit Bell=P3^7;
void timer (void) interrupt 1
{    
    P2=P2&0xc0;
    P2=P2|1<<Ledp;
    P0=LEDCODE[Disbuff][Ledp]];
    Ledp=(Ledp+1)%6;
}
void Delay (void)
{    unsigned int i;
    for(i=0;i<30000;i++) ;
    }

void main (void)
{
    
    unsigned int i;
    TMOD=0X01;
    TR0=1;
    ET0=1;
    EA=1;
    TL0=(65535-200)%256;
    TH0=(65535-200)/256;
    while (1)
    {
        Delay();
        Bell=~Bell;
         Disbuff[0]=(Disbuff[0]+1)%10;
        for (i=1; i<6; i++)
        { if(!Disbuff[i-1])
        Disbuff=(Disbuff+1)%10;
            else break;
            }
        }
    }

数码管的灯会闪,其他基本正常。
小弟我不怎么会用中断。
游客

返回顶部