单片机通过MAX7219级联8*8点阵做滚动效果的问题
时间:10-02
整理:3721RD
点击:
各位大神,本人是单片机小白一枚,最近用89C52单片机通过MAX7219级联点阵做滚动屏的效果,级联了8个8*8的led点阵,第五第六个点阵总是闪来闪去的,求各位大神帮帮忙,到底是什么问题https://share.weiyun.com/ea16151bd0710660bc739ca3425e20a2
链接里是录的情况,各位大神帮帮忙吧~~
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
//?Max7219?
sbit Max7219_pinCLK_1 = P2^2;
sbit Max7219_pinCS_1 = P2^1;
sbit Max7219_pinDIN_1 = P2^0;
uchar code disp1[16][8]={
{0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00},
{0x00,0x00,0x80,0xc0,0xc0,0x80,0x00,0x00},
{0x00,0x80,0xc0,0x60,0x60,0xc0,0x80,0x00},
{0x80,0xc0,0x60,0x30,0x30,0x60,0xc0,0x80},
{0xc0,0x60,0x30,0x18,0x18,0x30,0x60,0xc0},
{0x60,0x30,0x18,0x0c,0x0c,0x18,0x30,0x60},
{0x30,0x18,0x0c,0x06,0x06,0x0c,0x18,0x30},
{0x18,0x0c,0x06,0x03,0x03,0x06,0x0c,0x18},
{0x0c,0x06,0x03,0x01,0x01,0x03,0x06,0x0c},
{0x06,0x03,0x01,0x00,0x00,0x01,0x03,0x06},
{0x03,0x01,0x00,0x00,0x00,0x00,0x01,0x03},
{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
{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},
};//0
uchar code disp2[16][8]={
{0x0c,0x06,0x03,0x01,0x01,0x03,0x06,0x0c},
{0x06,0x03,0x01,0x00,0x00,0x01,0x03,0x06},
{0x03,0x01,0x00,0x00,0x00,0x00,0x01,0x03},
{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
{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,0x80,0x80,0x00,0x00,0x00},
{0x00,0x00,0x80,0xc0,0xc0,0x80,0x00,0x00},
{0x00,0x80,0xc0,0x60,0x60,0xc0,0x80,0x00},
{0x80,0xc0,0x60,0x30,0x30,0x60,0xc0,0x80},
{0xc0,0x60,0x30,0x18,0x18,0x30,0x60,0xc0},
{0x60,0x30,0x18,0x0c,0x0c,0x18,0x30,0x60},
{0x30,0x18,0x0c,0x06,0x06,0x0c,0x18,0x30},
{0x18,0x0c,0x06,0x03,0x03,0x06,0x0c,0x18},
};
void Delay_xms(uint x)
{
uint i,j;
for(i=0;i<x;i++)
for(j=0;j<112;j++);
}
void Write_Max7219_byte(uchar DATA)
{
uchar i;
Max7219_pinCS_1=0;
for(i=8;i>=1;i--)
{
Max7219_pinCLK_1=0;
Max7219_pinDIN_1=DATA&0x80;
DATA=DATA<<1;
Max7219_pinCLK_1=1;
}
}
void Write_Max7219_1(uchar address1,uchar dat1)
{
Max7219_pinCS_1=0;
Write_Max7219_byte(address1); //
Write_Max7219_byte(dat1); //
Max7219_pinCS_1=1;
}
void Write_Max7219_2(uchar address2,uchar dat2)
{
uchar i;
Max7219_pinCS_1=0;
Write_Max7219_byte(address2); //D′è?μ??·
Write_Max7219_byte(dat2); // D′è?êy?Y
Max7219_pinCLK_1=1;
for(i=1;i<3;i++)
{
Write_Max7219_byte(0x00); //??1D′??
}
Max7219_pinCS_1=1;
}
void Write_Max7219_3(uchar address3,uchar dat3)
{
uchar i;
Max7219_pinCS_1=0;
Write_Max7219_byte(address3); //
Write_Max7219_byte(dat3); //
Max7219_pinCLK_1=1;
for(i=1;i<5;i++)
{
Write_Max7219_byte(0x00); //
}
Max7219_pinCS_1=1;
}
void Write_Max7219_4(uchar address4,uchar dat4)
{
uchar i;
Max7219_pinCS_1=0;
Write_Max7219_byte(address4); //
Write_Max7219_byte(dat4); //
// Delay_xms(1000);
Max7219_pinCLK_1=1;
for(i=1;i<7;i++)
{
Write_Max7219_byte(0x00); //
}
Max7219_pinCS_1=1;
}
void Write_Max7219_5(uchar address5,uchar dat5)
{
uchar i;
Max7219_pinCS_1=0;
Write_Max7219_byte(address5); //
Write_Max7219_byte(dat5); //
Max7219_pinCLK_1=1;
for(i=1;i<9;i++)
{
Write_Max7219_byte(0x00); //
}
Max7219_pinCS_1=1;
}
void Write_Max7219_6(uchar address6,uchar dat6)
{
uchar i;
Max7219_pinCS_1=0;
Write_Max7219_byte(address6); //
Write_Max7219_byte(dat6); //
Max7219_pinCLK_1=1;
for(i=1;i<11;i++)
{
Write_Max7219_byte(0x00); //
}
Max7219_pinCS_1=1;
}
void Write_Max7219_7(uchar address7,uchar dat7)
{
uchar i;
Max7219_pinCS_1=0;
Write_Max7219_byte(address7); //
Write_Max7219_byte(dat7); //
Max7219_pinCLK_1=1;
for(i=1;i<13;i++)
{
Write_Max7219_byte(0x00); //
}
Max7219_pinCS_1=1;
}
void Write_Max7219_8(uchar address8,uchar dat8)
{
uchar i;
Max7219_pinCS_1=0;
Write_Max7219_byte(address8); //
Write_Max7219_byte(dat8); //
Max7219_pinCLK_1=1;
for(i=1;i<15;i++)
{
Write_Max7219_byte(0x00); //
}
Max7219_pinCS_1=1;
}
void Init_MAX7219(void)
{
Write_Max7219_1(0x09, 0x00); //ò???·?ê?£oBCD??
Write_Max7219_1(0x0a, 0x03); //áá?è
Write_Max7219_1(0x0b, 0x07); //é¨?è???T£?8??êy??1ü??ê?
Write_Max7219_1(0x0c, 0x01); //μ?μ??£ê?£o0£???í¨?£ê?£o1
Write_Max7219_1(0x0f, 0x00); //??ê?2aê?£o1£?2aê??áê?£??y3£??ê?£o0
Write_Max7219_2(0x09, 0x00); //
Write_Max7219_2(0x0a, 0x03); //
Write_Max7219_2(0x0b, 0x07); //
Write_Max7219_2(0x0c, 0x01); //
Write_Max7219_2(0x0f, 0x00); //
Write_Max7219_3(0x09, 0x00); //
Write_Max7219_3(0x0a, 0x03); //
Write_Max7219_3(0x0b, 0x07); //
Write_Max7219_3(0x0c, 0x01); //
Write_Max7219_3(0x0f, 0x00); //
Write_Max7219_4(0x09, 0x00); //
Write_Max7219_4(0x0a, 0x03); //
Write_Max7219_4(0x0b, 0x07); //
Write_Max7219_4(0x0c, 0x01); //
Write_Max7219_4(0x0f, 0x00); //
Write_Max7219_5(0x09, 0x00); //
Write_Max7219_5(0x0a, 0x03); //
Write_Max7219_5(0x0b, 0x07); //
Write_Max7219_5(0x0c, 0x01); //
Write_Max7219_5(0x0f, 0x00); //
Write_Max7219_6(0x09, 0x00); //
Write_Max7219_6(0x0a, 0x03); //
Write_Max7219_6(0x0b, 0x07); //
Write_Max7219_6(0x0c, 0x01); //
Write_Max7219_6(0x0f, 0x00); //
Write_Max7219_7(0x09, 0x00); //
Write_Max7219_7(0x0a, 0x03); //
Write_Max7219_7(0x0b, 0x07); //
Write_Max7219_7(0x0c, 0x01); //
Write_Max7219_7(0x0f, 0x00); //
Write_Max7219_8(0x09, 0x00); //
Write_Max7219_8(0x0a, 0x03); //
Write_Max7219_8(0x0b, 0x07); //
Write_Max7219_8(0x0c, 0x01); //
Write_Max7219_8(0x0f, 0x00); //
}
void main(void)
{
uchar i,j;
Delay_xms(50);
Init_MAX7219();
while(1)
{
for(j=0;j<16;j++)
{
for(i=1;i<9;i++)
{
Write_Max7219_1(i,disp1[j][i-1]);
// Delay_xms(400);
Write_Max7219_2(i,disp2[j][i-1]);
// Delay_xms(3000);
Write_Max7219_3(i,disp1[j][i-1]);
// Delay_xms(400);
Write_Max7219_4(i,disp2[j][i-1]);
// Delay_xms(400);
Write_Max7219_5(i,disp1[j][i-1]);
// Delay_xms(3000);
Write_Max7219_6(i,disp2[j][i-1]);
// Delay_xms(1000);
Write_Max7219_7(i,disp1[j][i-1]);
// Delay_xms(400);
Write_Max7219_8(i,disp2[j][i-1]);
// Delay_xms(400);
}
Delay_xms(100);
}
}
}
加微信聊么?也有点问题想问