请教各位为什么会变成点阵上一行一行全亮扫描的?

2019-07-16 04:26发布

#include<reg52.h>
/*p10单元板显示有电两字;32*16点阵,由74HC595窜入并出控制列,74HC138做行扫描,STC89C52微控制器*/
sbit s=P3^3;  
sbit SH_CP=P3^6;//数据
sbit ST_CP=P3^7;//锁存
sbit a=P3^0;
sbit b=P3^1;

char code duan_dian[4][64]={
0x00,0x02,0x20,0x00,0x00,0x01,0x20,0x00,
0xFC,0x7F,0x20,0x00,0x80,0x00,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x00,0xFF,0x1F,0x20,0x00,0x21,0x10,
0xF0,0x1F,0x21,0x10,0x18,0x10,0xFF,0x1F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xF4,0x1F,0x21,0x10,0x12,0x10,0x21,0x10,
0xF1,0x1F,0x21,0x10,0x10,0x10,0xFF,0x1F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x10,0x20,0x00,0x10,0x10,0x20,0x40,
0x10,0x1C,0x60,0x40,0x00,0x00,0xE0,0x7F,
};
void main()
{
char m,n,k,date;
a=0;
b=0;
while(1)
{ for(n=0;n<4;n++)
   {  for(m=63;m>0;m--)
       {date=duan_dian[n][m];//将数组元素给date
         for(k=0;k<8;k++)
            {date=date<<1;//date左移
             s=CY;//CY给s
             SH_CP=0;
             SH_CP=1;//上升沿来,s输出
                        
            }
       }
    if(n==0)//判定n==0,138行扫描信号为00,上升沿来,595锁存器输出,第一行显示
    {ST_CP=0;ST_CP=1;a=0;b=0;}
    else if(n==1)//判定n==1,138行扫描信号为01,上升沿来,595锁存器输出,第二行显示
    {ST_CP=0;ST_CP=1;a=1;b=0;}
    else if(n==2)//判定n==2,138行扫描信号为10,上升沿来,595锁存器输出,第三行显示
    {ST_CP=0;ST_CP=1;a=0;b=1;}
    else if(n==3)//判定n==3,138行扫描信号为00,上升沿来,595锁存器输出,第四行显示
    {ST_CP=0;ST_CP=1;a=1;b=1;}
    else;
    }
}

}       
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
652019299
1楼-- · 2019-07-16 09:04
不知是不是595中数据没有传输正确?
lstcspring
2楼-- · 2019-07-16 11:20
             SH_CP=0;
             SH_CP=1;//上升沿来,s输出
加点延时
652019299
3楼-- · 2019-07-16 14:25
谢谢啊!加延时的确好啦!

一周热门 更多>