微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 请教各位为什么会变成点阵上一行一行全亮扫描的?

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

时间:10-02 整理:3721RD 点击:
#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;
    }
}
}       

不知是不是595中数据没有传输正确?

             SH_CP=0;
             SH_CP=1;//上升沿来,s输出
加点延时

谢谢啊!加延时的确好啦!

上一篇:请高手指点!
下一篇:遇到麻烦了

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top