找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

PIC16F877A单片机驱动max7219时点阵有残影闪烁

查看数: 4993 | 评论数: 16 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2019-10-12 21:20

正文摘要:

877a驱动max7219驱动4块8*8级联成4*32,显示时在第三块总是有残影,另外3块确没有,请问是代码问题吗?谢谢了! 单片机源程序如下: #include <pic.h> __CONFIG(HS&WDTDIS&LVPDIS); #define INT8U& ...

回复

ID:371546 发表于 2022-3-6 09:07
多级串联的时候,写入数据的过程中,不用的位要写NO-OP代码,这样就不会重影了。

评分

参与人数 1黑币 +20 收起 理由
admin + 20 回帖助人的奖励!

查看全部评分

ID:371546 发表于 2022-3-6 09:05
本帖最后由 ldch88 于 2022-3-6 11:03 编辑

//-----------------------------------------------------------------------------
//向MAX7219写入字节
//-----------------------------------------------------------------------------
void Write_Max7219_byte(INT8U DATA)         

{
        INT8U i;   
        CS=0;                                //CS=0有效,CS=1锁存        
        for(i=8;i>=1;i--)
                {
                        CLK=0;
                        if(DATA & 0x80) DIN=1; else DIN=0;
                        DATA=DATA<<1;
                        CLK=1;                //上升沿把数据送出去
                }                                 
}
//------------------------------------------------------------------
//向M第一片MAX7219写入数据
//------------------------------------------------------------------
void Write_Max7219_1(INT8U add1,INT8U dat1)
{
        //CS=0;
        Write_Max7219_byte(0x00);        //片8写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片7写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片6写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片5写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片4写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片3写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片2写入空
        Write_Max7219_byte(0x00);
        
        Write_Max7219_byte(add1);        //片1写入地址,即数码管编号
        Write_Max7219_byte(dat1);        //片1写入数据,即数码管显示数字
        CS=1;                        
}
//---------------------------------------------------------------------
//第二片MAX7219的写入数据
//---------------------------------------------------------------------
void Write_Max7219_2(INT8U add2,INT8U dat2)
{
        //CS=0;
        Write_Max7219_byte(0x00);        //片8写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片7写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片6写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片5写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片4写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片3写入空
        Write_Max7219_byte(0x00);
        
        Write_Max7219_byte(add2);        //片2写入地址,即数码管编号
        Write_Max7219_byte(dat2);        //片2写入数据,即数码管显示数字
        
        Write_Max7219_byte(0x00);        //片1写入空
        Write_Max7219_byte(0x00);
        CS=1;
}
//---------------------------------------------------------------------
//第三片MAX7219的写入数据
//---------------------------------------------------------------------
void Write_Max7219_3(INT8U add3,INT8U dat3)
{
        //CS=0;
        Write_Max7219_byte(0x00);        //片8写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片7写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片6写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片5写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片4写入空
        Write_Max7219_byte(0x00);
        
        Write_Max7219_byte(add3);        //片3写入地址,即数码管编号
        Write_Max7219_byte(dat3);        //片3写入数据,即数码管显示数字
        
        Write_Max7219_byte(0x00);        //片2写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片1写入空
        Write_Max7219_byte(0x00);
        CS=1;
}
//---------------------------------------------------------------------
//第四片MAX7219的写入数据
//---------------------------------------------------------------------
void Write_Max7219_4(INT8U add4,INT8U dat4)
{
        //CS=0;
        Write_Max7219_byte(0x00);        //片8写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片7写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片6写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片5写入空
        Write_Max7219_byte(0x00);
        
        Write_Max7219_byte(add4);        //片4写入地址,即数码管编号
        Write_Max7219_byte(dat4);        //片4写入数据,即数码管显示数字
        
        Write_Max7219_byte(0x00);        //片3写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片2写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片1写入空
        Write_Max7219_byte(0x00);
        CS=1;
}
//---------------------------------------------------------------------
//第五片MAX7219的写入数据
//---------------------------------------------------------------------
void Write_Max7219_5(INT8U add5,INT8U dat5)
{
        //CS=0;
        Write_Max7219_byte(0x00);        //片8写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片7写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片6写入空
        Write_Max7219_byte(0x00);
        
        Write_Max7219_byte(add5);        //片5写入地址,即数码管编号
        Write_Max7219_byte(dat5);        //片5写入数据,即数码管显示数字
        
        Write_Max7219_byte(0x00);        //片4写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片3写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片2写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片1写入空
        Write_Max7219_byte(0x00);
        CS=1;
}
//---------------------------------------------------------------------
//第六片MAX7219的写入数据
//---------------------------------------------------------------------
void Write_Max7219_6(INT8U add6,INT8U dat6)
{
        //CS=0;
        Write_Max7219_byte(0x00);        //片8写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片7写入空
        Write_Max7219_byte(0x00);
        
        Write_Max7219_byte(add6);        //片6写入地址,即数码管编号
        Write_Max7219_byte(dat6);        //片6写入数据,即数码管显示数字
        
        Write_Max7219_byte(0x00);        //片5写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片4写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片3写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片2写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片1写入空
        Write_Max7219_byte(0x00);
        CS=1;
}
//---------------------------------------------------------------------
//第七片MAX7219的写入数据
//---------------------------------------------------------------------
void Write_Max7219_7(INT8U add7,INT8U dat7)
{
        //CS=0;
        Write_Max7219_byte(0x00);        //片8写入空
        Write_Max7219_byte(0x00);
        
        Write_Max7219_byte(add7);        //片7写入地址,即数码管编号
        Write_Max7219_byte(dat7);        //片7写入数据,即数码管显示数字
        
        Write_Max7219_byte(0x00);        //片6写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片5写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片4写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片3写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片2写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片1写入空
        Write_Max7219_byte(0x00);
        CS=1;
}
//---------------------------------------------------------------------
//第八片MAX7219的写入数据
//---------------------------------------------------------------------
void Write_Max7219_8(INT8U add8,INT8U dat8)
{
        //CS=0;
        Write_Max7219_byte(add8);        //片8写入地址,即数码管编号
        Write_Max7219_byte(dat8);        //片8写入数据,即数码管显示数字
        
        Write_Max7219_byte(0x00);        //片7写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片6写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片5写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片4写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片3写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片2写入空
        Write_Max7219_byte(0x00);
        Write_Max7219_byte(0x00);        //片1写入空
        Write_Max7219_byte(0x00);
        CS=1;
}
//---------------------------------------------------------------------
//初始化芯片
//---------------------------------------------------------------------
void Init_MAX7219(void)
{
        Write_Max7219_1(0x09, 0x00);       //译码方式:不译码
        Write_Max7219_1(0x0a, 0x03);       //设定亮度
        Write_Max7219_1(0x0b, 0x07);       //扫描界限;8个数码管显示
        Write_Max7219_1(0x0c, 0x01);       //掉电模式:0,普通模式:1
        Write_Max7219_1(0x0f, 0x00);       //显示测试:1;测试结束,正常显示:0
        
        Write_Max7219_2(0x09, 0x00);       //译码方式:不译码
        Write_Max7219_2(0x0a, 0x03);       //设定亮度  
        Write_Max7219_2(0x0b, 0x07);       //扫描界限;8个数码管显示
        Write_Max7219_2(0x0c, 0x01);       //掉电模式:0,普通模式:1
        Write_Max7219_2(0x0f, 0x00);       //显示测试:1;测试结束,正常显示:0
        
        Write_Max7219_3(0x09, 0x00);       //译码方式:不译码
        Write_Max7219_3(0x0a, 0x03);       //设定亮度  
        Write_Max7219_3(0x0b, 0x07);       //扫描界限;8个数码管显示
        Write_Max7219_3(0x0c, 0x01);       //掉电模式:0,普通模式:1
        Write_Max7219_3(0x0f, 0x00);       //显示测试:1;测试结束,正常显示:0
        
        Write_Max7219_4(0x09, 0x00);       //译码方式:不译码
        Write_Max7219_4(0x0a, 0x02);       //设定亮度  
        Write_Max7219_4(0x0b, 0x07);       //扫描界限;8个数码管显示
        Write_Max7219_4(0x0c, 0x01);       //掉电模式:0,普通模式:1
        Write_Max7219_4(0x0f, 0x00);       //显示测试:1;测试结束,正常显示:0
        
        Write_Max7219_5(0x09, 0x00);       //译码方式:不译码
        Write_Max7219_5(0x0a, 0x03);       //设定亮度  
        Write_Max7219_5(0x0b, 0x07);       //扫描界限;8个数码管显示
        Write_Max7219_5(0x0c, 0x01);       //掉电模式:0,普通模式:1
        Write_Max7219_5(0x0f, 0x00);       //显示测试:1;测试结束,正常显示:0
        
        Write_Max7219_6(0x09, 0x00);       //译码方式:不译码
        Write_Max7219_6(0x0a, 0x03);       //设定亮度
        Write_Max7219_6(0x0b, 0x07);       //扫描界限;8个数码管显示
        Write_Max7219_6(0x0c, 0x01);       //掉电模式:0,普通模式:1
        Write_Max7219_6(0x0f, 0x00);       //显示测试:1;测试结束,正常显示:0
        
        Write_Max7219_7(0x09, 0x00);       //译码方式:不译码
        Write_Max7219_7(0x0a, 0x03);       //设定亮度  
        Write_Max7219_7(0x0b, 0x07);       //扫描界限;8个数码管显示
        Write_Max7219_7(0x0c, 0x01);       //掉电模式:0,普通模式:1
        Write_Max7219_7(0x0f, 0x00);       //显示测试:1;测试结束,正常显示:0
        
        Write_Max7219_8(0x09, 0x00);       //译码方式:不译码
        Write_Max7219_8(0x0a, 0x03);       //设定亮度  
        Write_Max7219_8(0x0b, 0x07);       //扫描界限;8个数码管显示
        Write_Max7219_8(0x0c, 0x01);       //掉电模式:0,普通模式:1
        Write_Max7219_8(0x0f, 0x00);       //显示测试:1;测试结束,正常显示:0
}

评分

参与人数 1黑币 +20 收起 理由
admin + 20 回帖助人的奖励!

查看全部评分

ID:420836 发表于 2021-8-27 08:43
想知道问题是如何解决的。7 段 LED 显示编程时,必须先将之前的数字完全清除才能显示新的数字,以免出现重影。
ID:332444 发表于 2021-8-26 17:00
消隐有软消隐与硬消隐,软消隐就是送灯熄灭的值,硬消隐控制芯片清零引脚的值.
ID:332444 发表于 2021-8-26 16:56
基本就是消隐存在问题
ID:215984 发表于 2021-8-26 16:37
楼主还上线吗?我也出现了此种情况,麻烦你告知原因,谢谢!
ID:917386 发表于 2021-6-26 13:42
请问怎么解决的
ID:258542 发表于 2020-7-12 16:12
我和楼主碰到一样的问题了,弄了好几天都没解决,请问下楼主是您代码哪里的问题呢?
ID:147616 发表于 2020-2-20 20:40
怎么解决的
ID:649963 发表于 2019-11-26 15:06
代码问题,认真看可以发现残影都是其他出现的字体。
ID:48140 发表于 2019-11-26 10:53
怎么解决的?
ID:45497 发表于 2019-10-15 14:14
代码问题,已解决了。
ID:45497 发表于 2019-10-14 21:54
发现残影就是第一片的数据,不知是什么原因,看代码是应该没有显示的。
ID:617981 发表于 2019-10-14 17:23
代码问题,认真看可以发现残影都是其他出现的字体。
ID:45497 发表于 2019-10-14 14:19
请问有人碰到过吗?
ID:45497 发表于 2019-10-12 21:22

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表