|
本帖最后由 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 } |
| 想知道问题是如何解决的。7 段 LED 显示编程时,必须先将之前的数字完全清除才能显示新的数字,以免出现重影。 |
| 消隐有软消隐与硬消隐,软消隐就是送灯熄灭的值,硬消隐控制芯片清零引脚的值. |
| 基本就是消隐存在问题 |
| 楼主还上线吗?我也出现了此种情况,麻烦你告知原因,谢谢! |
| 请问怎么解决的 |
| 我和楼主碰到一样的问题了,弄了好几天都没解决,请问下楼主是您代码哪里的问题呢? |
| 怎么解决的 |
| 代码问题,认真看可以发现残影都是其他出现的字体。 |
| 怎么解决的? |
| 代码问题,已解决了。 |
| 发现残影就是第一片的数据,不知是什么原因,看代码是应该没有显示的。 |
| 代码问题,认真看可以发现残影都是其他出现的字体。 |
| 请问有人碰到过吗? |