是不是程序的问题,看了几天不知道错误在哪,请大神帮忙看看
#include <reg52.h>sbit dx=P2^0;sbit wx=P2^1;unsigned int shi,ge,num=0;unsigned char code table[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};void delays(unsigned int xms){ unsigned int i,j; for(i=xms;i>0;i--) for(j=110;j>0;j--) ;}void display(unsigned char shi,unsigned char ge){ wx=1; P0=table[ge]; wx=0; dx=1; P3=0x02; wx=0; delays(5);
wx=1; P0=table[shi]; wx=0; dx=1; P3=0x01; dx=0; delays(5);}void main(){ unsigned temp; temp=31; TMOD=0x01; TH0=(65536-50000)/256; TL0=(65536-50000)%256; EA=1; ET0=1; TR0=1; while(1) {
if(num==20) {num=0; temp--; shi=temp/10; ge=temp%10; } if(temp==0) temp=31; display(shi,ge);} } void time() interrupt 1{ TH0=(65536-50000)/256; TL0=(65536-50000)%256; num++;}
仿真的时候数码管处于常亮状态,俩个八,带小数点都亮,不会变化
追答你的数码管是共阴极的?还是共阳极的?
从 table[]={0xc0,0xf9,0xa4,0xb0,看来是共阳极数码管,但,可能你用错了共阴极了
可以发给我看看
或者给你做一份
我做单片机的