六个595驱动点阵
请教大家
为什么最后一列总是有点乱
这是显示三列
这是显示两列
这是显示一列,怎么还重复了。
这是显示四列
代码是这样的
#include<stc15.h>
sbit Data = P2^0;
sbit OE =P2^3;
sbit L_STB = P2^1;
sbit L_CLK= P2^2;
unsigned char code ROW_NUM[] = {
0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x01, 0x00,
0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x01,
};
unsigned char code a[][16] ={
{0x01,0x01,0x3F,0x01,0x1F,0x02,0xFF,0x04,0x08,0x3F,0xC8,0x0F,0x08,0x08,0x0F,0x00},//春
{0x00,0x00,0xFC,0x00,0xF8,0x00,0xFE,0x20,0x18,0xEE,0x24,0xE0,0x20,0x20,0xE0,0x00},
{0x04,0x04,0xFF,0x04,0x04,0x00,0x3F,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02},//节
{0x20,0x20,0xFE,0x20,0x20,0x00,0xF8,0x08,0x08,0x08,0x08,0x28,0x10,0x00,0x00,0x00},
};
unsigned char row=0;//当前扫描行
void SendByte(unsigned char wdata)
{
unsigned char i;
for(i=0;i<8;i++)
{
L_CLK=0;//时钟拉低
Data=wdata&0x80;
L_CLK=1;//时钟拉高,产生上升沿
wdata <<= 1;//左移一位
}
}
void main()
{
P2M0=0;P2M1=0;P1M0=0;P1M1=0;P0M0=0;P0M1=0;P3M0=0;P3M1=0;P4M0=0;P4M1=0;P5M0=0; P5M1=0;P6M0=0;P6M1=0;P7M0=0;P7M1=0;
OE=0; //开显示屏
while(1)
{
unsigned char j;
for(row=0;row<16;row++) //当前扫描的行
{
for (j=0;j<3;j++)
SendByte(~a[j][row]);//送j列数据,取反
SendByte(ROW_NUM[row*2+1]);//送第二行数据
SendByte(ROW_NUM[row*2]);//送第一行数据
L_STB=0;
L_STB=1;
}
}
}
请教大家
为什么最后一列总是有点乱
这是显示三列
这是显示两列
这是显示一列,怎么还重复了。
这是显示四列
代码是这样的
#include<stc15.h>
sbit Data = P2^0;
sbit OE =P2^3;
sbit L_STB = P2^1;
sbit L_CLK= P2^2;
unsigned char code ROW_NUM[] = {
0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x01, 0x00,
0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x01,
};
unsigned char code a[][16] ={
{0x01,0x01,0x3F,0x01,0x1F,0x02,0xFF,0x04,0x08,0x3F,0xC8,0x0F,0x08,0x08,0x0F,0x00},//春
{0x00,0x00,0xFC,0x00,0xF8,0x00,0xFE,0x20,0x18,0xEE,0x24,0xE0,0x20,0x20,0xE0,0x00},
{0x04,0x04,0xFF,0x04,0x04,0x00,0x3F,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02},//节
{0x20,0x20,0xFE,0x20,0x20,0x00,0xF8,0x08,0x08,0x08,0x08,0x28,0x10,0x00,0x00,0x00},
};
unsigned char row=0;//当前扫描行
void SendByte(unsigned char wdata)
{
unsigned char i;
for(i=0;i<8;i++)
{
L_CLK=0;//时钟拉低
Data=wdata&0x80;
L_CLK=1;//时钟拉高,产生上升沿
wdata <<= 1;//左移一位
}
}
void main()
{
P2M0=0;P2M1=0;P1M0=0;P1M1=0;P0M0=0;P0M1=0;P3M0=0;P3M1=0;P4M0=0;P4M1=0;P5M0=0; P5M1=0;P6M0=0;P6M1=0;P7M0=0;P7M1=0;
OE=0; //开显示屏
while(1)
{
unsigned char j;
for(row=0;row<16;row++) //当前扫描的行
{
for (j=0;j<3;j++)
SendByte(~a[j][row]);//送j列数据,取反
SendByte(ROW_NUM[row*2+1]);//送第二行数据
SendByte(ROW_NUM[row*2]);//送第一行数据
L_STB=0;
L_STB=1;
}
}
}