完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
本帖最后由 流芷静兰 于 2017-2-25 10:35 编辑
各位大神,本人是单片机小白一枚,最近用89C52单片机通过MAX7219级联点阵做滚动屏的效果,级联了8个8*8的led点阵,第五第六个点阵总是闪来闪去的,求各位大神帮帮忙,到底是什么问题https://share.weiyun.com/ea16151bd0710660bc739ca3425e20a2 链接里是录的情况,各位大神帮帮忙吧~~ #include #include #define uchar unsigned char #define uint unsigned int //??Max7219?? ***it Max7219_pinCLK_1 = P2^2; ***it Max7219_pinCS_1 = P2^1; ***it 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 } 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); //дÈëµØÖ· Write_Max7219_byte(dat2); // дÈëÊý¾Ý Max7219_pinCLK_1=1; for(i=1;i<3;i++) { Write_Max7219_byte(0x00); //Ƭ1д¿Õ } 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); //ÒëÂ뷽ʽ£ºBCDÂë 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); // 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); } } } |
|
相关推荐
1个回答
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
求解外围电路实现的是4脚给持续低电平复位并正常工作,高电平不工作的原因
2114 浏览 1 评论
3675 浏览 3 评论
PIC1946程序有一个变量在运行过程中恢复初始值其他变量保持不变
2360 浏览 2 评论
2784 浏览 0 评论
PIC16F1825的RC5引脚,在主程序中操作无效,在中断中可以改变是为什么?
4076 浏览 5 评论
1015浏览 0评论
用XC8编译PIC18F25K80时提示下面Error,求怎么解决这个问题
6401浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-30 09:42 , Processed in 0.759227 second(s), Total 76, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号