在做单片机静态显示的时候想显示520,但是无法完成,看程序也没问题啊
这是我的主程序:
#include<reg51.H>
sbit P3_7=P3^7;
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char cun;
void delay(unsigned int time){
unsigned int j=0;
for (;time>0;time--)
for (j=0;j<125;j++);
}
void main (void){
cun=257;
P0=table[cun/100];
P2=table[cun/10%10];
P1=table[cun%10];
while(1){
if(P3_7==0){
delay(10);
if(P3_7==0){
cun++;
if(cun==100)
cun=0;
P0=table[cun/100];
P2=table[cun/10%10];
P1=table[cun%10];
while(P3_7==0);}}}}
可以排除是电脑原因,我用室友电脑试了一下结果一样
在仿真时发现三位数码显示最多只能打到255,再按就会归零
包括直接在程序里设置cun的初始值也最多只能设置到255,设置256仿真结果就会变0
搞不懂什么原因