图片是我
开发板的原理图,我写了一程序,想让LED灯闪烁,同时数码管数字在跑!但是我的开发板上LED和数码管在一个端口,P0口,所以LED闪烁每次都没安程序闪,求哪位大侠指点一下,在不改动开发板的情况下让LED安程序闪烁!下面是我写的程序:
- #include<reg52.h>
- #include<intrins.h>
- #define uli unsigned long int
- #define uchar unsigned char
- uchar code shuma[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x76,0x79,0x38,0x38,0x3f,0x00};
- uchar led;
- uli t0,t1,g,h,x,D,E,F;
- void dealy();
- void xianshi(uli A,uli B,uli C,uli D,uli E,uli F);
- void chushi();
- void main()
- {
- chushi();
- while(1)
- {
- if(h!=1)
- xianshi(7,6,5,D,E,F);
- else
- xianshi(10,11,12,13,14,15);
- }
- }
- void chushi()
- {
- x=432;
- led=0xfe;
- P0=led;
- TMOD=0x11;
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- TH1=(65536-50000)/256;
- TL1=(65536-50000)%256;
- EA=1;
- ET0=1;
- ET1=1;
- TR0=1;
- TR1=1;
- }
- void zhduan() interrupt 1
- {
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- t0++;
- if(g!=1)
- {
- if(t0==10)
- {
- t0=0;
- led=_crol_(led,1);
- P0=led;
- P0=0;
- }
- }
- else
- {
- if(t0%4==0)
- P0=~P0;
- if(t0==60)
- {
- TR0=0;
- P0=0xff;
- h=1;
- }
- }
- }
- void zhuduan() interrupt 3
- {
- TH1=(65536-50000)/256;
- TL1=(65536-50000)%256;
- t1++;
- if(t1==2)
- {
- t1=0;
- x--;
- D=x/100;
- E=x%100/10;
- F=x%10;
- if(x==398)
- {
- TR0=0;
- TH0=(65536-50000)/256;
- TL0=(65536-50000)%256;
- TR0=1;
- g=1;
- t0=0;
- P0=0xff;
- TR1=0;
- }
- }
- }
- void xianshi(uli A,uli B,uli C,uli D,uli E,uli F)
- {
- P0=0;
- P2=0;
- P0=shuma[A];
- dealy();
- P0=0;
- P2=1;
- P0=shuma[B];
- dealy();
- P0=0;
- P2=2;
- P0=shuma[C];
- dealy();
- P0=0;
- P2=3;
- P0=shuma[D];
- dealy();
- P0=0;
- P2=4;
- P0=shuma[E];
- dealy();
- P0=0;
- P2=5;
- P0=shuma[F];
- dealy();
- }
- void dealy()
- {
- uli i,j;
- for(i=0;i<3;i++)
- for(j=0;j<1;j++);
- }
复制代码
-
开发板电路图
-
开发板电路图
一周热门 更多>