利用片外RAM 扩展12位数码管,同时显示,仿真不显示,
实际电路显示,但数码管闪烁。求助,数码管如何才能不
闪烁?程序有问题?还是这种扩展方式不行?求教各位。多谢了。
单片机源程序如下:
- #include<reg52.h>
- #include<absacc.h>
- #define hc273_U3 XBYTE[0x1fff] //Y0:0x1fff(无关位用1),U1 74HC273 ,段码 四位
- #define hc273_U6 XBYTE[0x7fff] //Y3:0x7fff(无关位用1),U6 74Hc273 ,位选
- #define hc273_U5 XBYTE[0x5fff] //Y2:0x5fff(无关位用1),U3 74HC273 ,段码 四位
- #define hc273_U4 XBYTE[0x3fff] //Y1:0x5fff(无关位用1),U1 74HC273 ,段码 四位
- unsigned char code c[10] = {0x81,0xcf,0x92,0x86,0xcc,0xa4,0xa0,0x8f,0x80,0x84}; // 数码管0-9段码 共阳数码管(部分改动)
- unsigned char code w[5] = {0xfe,0xfd,0xfb,0xf7};//数码管位码
-
- void main()
- {
- unsigned int t;
- unsigned char i;
- unsigned char PA = 0x01;
- unsigned char a[4] = {2,3,4,5};
- unsigned char b[4] = {7,8,0,9};
- unsigned char e[4] = {1,6,8,3};
- while(1)
- {
-
- for(i=0;i<4;i++)
- {
- hc273_U3 = c[a[i]];
- hc273_U4 = c[b[i]];
- hc273_U5 = c[e[i]];
- hc273_U6 = ~PA;
- for(t=0;t<1000;t++);
- PA<<=1;
- }
- PA = 0x01;
- }
- }
复制代码
|