|
本帖最后由 飞剑 于 2013-11-22 18:08 编辑
硬件:STCC5A60S2+P10户外单元板
问题:在被点亮的LED周围的LED也会微微有点亮。
比如上面的图片,显示0000,在0的周围,有几个不该亮的LED也微微发光,请高手帮忙分析一下。- #include <reg52.h>
- #include <intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define NOP _nop_()
- sbit OE = P1^2;
- sbit A1 = P1^3;
- sbit B1 = P1^4;
- sbit SHCP=P1^5; //ÒÆλʱÖÓ
- sbit STCP=P1^6; //Ëø´æʱÖÓ
- sbit DATA=P1^7;
- uchar code NUMBER[160]=
- {0xFF,0xFF,0xFF,0xE7,0xDB,0xBD,0xBD,0xBD,0xBD,0xBD,0xBD,0xBD,0xDB,0xE7,0xFF,0xFF, //显示0
- 0xFF,0xFF,0xFF,0xEF,0x8F,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0x83,0xFF,0xFF, //1
- 0xFF,0xFF,0xFF,0xC3,0xBD,0xBD,0xBD,0xFB,0xFB,0xF7,0xEF,0xDF,0xBD,0x81,0xFF,0xFF, //2
- 0xFF,0xFF,0xFF,0xC3,0xBD,0xBD,0xFB,0xE7,0xFB,0xFD,0xFD,0xBD,0xBB,0xC7,0xFF,0xFF, //3
- 0xFF,0xFF,0xFF,0xFB,0xF3,0xEB,0xDB,0xDB,0xBB,0xBB,0x81,0xFB,0xFB,0xE1,0xFF,0xFF, //4
- 0xFF,0xFF,0xFF,0x81,0xBF,0xBF,0xBF,0xA7,0x9B,0xFD,0xFD,0xBD,0xBB,0xC7,0xFF,0xFF, //5
- 0xFF,0xFF,0xFF,0xE3,0xDB,0xBF,0xBF,0xA7,0x9B,0xBD,0xBD,0xBD,0xDB,0xE7,0xFF,0xFF, //6
- 0xFF,0xFF,0xFF,0x81,0xBB,0xBB,0xF7,0xF7,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xFF,0xFF, //7
- 0xFF,0xFF,0xFF,0xC3,0xBD,0xBD,0xBD,0xDB,0xE7,0xDB,0xBD,0xBD,0xBD,0xC3,0xFF,0xFF, //8
- 0xFF,0xFF,0xFF,0xE7,0xDB,0xBD,0xBD,0xBD,0xD9,0xE5,0xFD,0xFD,0xDB,0xC7,0xFF,0xFF}; //9
- uchar table[2][32];
- uchar xianshi[4]={1,2,3,4};
- void serial_input(uchar dat)
- {
- uint m;
- for(m=0;m<8;m++)
- {
- if(dat & 0x80)
- DATA=1;
- else
- DATA=0;
- SHCP=0;
- NOP;
- NOP;
- SHCP=1;
- NOP;
- NOP;
- SHCP=0;
- dat=dat<<1;
- }
- }
- void serial_output()
- {
- STCP=1;
- NOP;
- NOP;
- STCP=0;
- }
- void HC138_scan(uchar temp)
- {
- OE=1;
- A1=0x01 & temp;
- B1=0x01 &(temp>>1);
- }
- void display()
- {
- uint i,j,k;
- for(k=0;k<4;k++) //ÏÔʾµÄ4ÐÐ
- {
- for(j=0;j<2;j++) //ÏÔʾ3¡¢4ÁÐ
- {
- for(i=0;i<2;i++) //ÏÔʾ1¡¢2ÁÐ
- {
- serial_input(table[j][3*8+2*k+i]);
- serial_input(table[j][2*8+2*k+i]);
- serial_input(table[j][1*8+2*k+i]);
- serial_input(table[j][0*8+2*k+i]);
- }
- }
- serial_output();
- HC138_scan(k);
- }
- }
- void xianshi_set()
- {
- int abc=0,abcd;
- abcd=0;
- for (abc=0;abc<16;abc++)
- {
- table[0][abcd]=NUMBER[abc+xianshi[0]*16];
- abcd=abcd+2;
- }
- abcd=1;
- for (abc=0;abc<16;abc++)
- {
- table[0][abcd]=NUMBER[abc+xianshi[1]*16];
- abcd=abcd+2;
- }
- abcd=0;
- for (abc=0;abc<16;abc++)
- {
- table[1][abcd]=NUMBER[abc+xianshi[2]*16];
- abcd=abcd+2;
- }
- abcd=1;
- for (abc=0;abc<16;abc++)
- {
- table[1][abcd]=NUMBER[abc+xianshi[3]*16];
- abcd=abcd+2;
- }
- }
- void main()
- {
- xianshi_set();
- while(1)
- {
- display();
- }
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|