请问用AT89C51制作计数器,在proteus仿真,运行的时候不会计数,只是数码管亮,请问哪里出错了?谢谢!
代码如下:#include<reg51.h>#include<absacc.h>#defineucharunsignedchar#defineuintunsignedin...
代码如下:#include<reg51.h>#include<absacc.h>#define uchar unsigned char#define uint unsigned int sbit key=P3^7;sbit rest=P3^6;uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};void delay10ms(void){ unsigned char a,b,c; for(c=1;c>0;c--) for(b=38;b>0;b--) for(a=130;a>0;a--);}void main (void){ uint Count=0; P0=0x3f; P1=0x3f; P2=0x3f; while(1) { if(rest==0) { delay10ms(); if(rest==0) while(rest==0) { Count=0; P0=table[Count/100]; P1=table[(Count%100)/10]; P2=table[Count%10]; } } if(key==0) { delay10ms(); if(key==0) { while(key==0); { Count++; if(Count==1000) Count=0; P0=table[Count/100]; P1=table[(Count%100)/10]; P2=table[Count%10]; } } } }}
展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询