找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1364|回复: 5
收起左侧

单片机74HC595点阵数据传输有错误

[复制链接]
ID:836542 发表于 2021-1-11 15:38 | 显示全部楼层 |阅读模式
51hei截图20210111152800.png
代码和仿真都发上了
显示1是正常的,其他的就开始乱了

这个是显示1、2、3
  1. #include<reg51.h>
  2. #include "intrins.h"
  3. #include "char.h"
  4. #define uint unsigned int
  5. #define uchar unsigned char
  6. sbit ser=P0^3;//ser 14
  7. sbit sck=P0^4;//sck 11
  8. sbit rck=P0^5;//rck 12
  9. sbit rst=P3^0;//复位信号
  10. //==============================================================
  11. void delay(uint ii){uint i;for(i=0;i<ii;i++);}
  12. //==============================================================
  13. void SendByte(uchar cc)         //发送
  14. {
  15.         uchar c=cc;
  16.         int i;
  17.   //=串行发送=
  18.   for(i=0;i<8;i++)
  19.   {            sck=0;
  20.                   ser=c>>7;
  21.                 c<<=1;
  22.                 sck=1;
  23.            }
  24.            //=并行发送=
  25.            rck=1;
  26.            _nop_();
  27.        _nop_();
  28.            rck=0;
  29.            //=复位=
  30.            rst=0;
  31.                 _nop_();
  32.        _nop_();
  33.            rst=1;
  34.            }

  35. //==============================================================
  36. void PutChar(char ci) //分解
  37. {
  38.         int i,j;
  39.   for(i=0;i<200;i++)
  40.   for(j=0;j<6;j++)
  41.   {
  42.           P1=j;         
  43.           SendByte(vc[ci-0x20][j]); //ASCII
  44.         _nop_();
  45.     _nop_();
  46.         SendByte(0);
  47.   }
  48. }
  49. //=============================================================
  50. void PutStr(char *str)
  51. {int i=0;
  52. while(str[i]!=0)
  53. {
  54.          PutChar(str[i]);
  55.          i++;
  56. }

  57. }
  58. //============================================================
  59. void main()
  60. {
  61.         rck=0;
  62.   while(1){
  63.           PutStr("123");
  64.         
  65.   }
  66. }

复制代码



1.zip (55.83 KB, 下载次数: 8)
回复

使用道具 举报

ID:390416 发表于 2021-1-11 16:08 | 显示全部楼层
89单片机+四个74HC595的LED16x16点阵 程序源码原理图 你可以用我们的代码
http://www.51hei.com/bbs/dpj-200961-1.html
回复

使用道具 举报

ID:332444 发表于 2021-1-11 16:28 | 显示全部楼层
  1. void PutChar(char ci) //分解
  2. {
  3.         int i,j;
  4.   for(i=0;i<200;i++)
  5.   for(j=0;j<=6;j++)
  6.   {
  7.           P1=j;         
  8.           SendByte(vc[ci-0x20][j]); //ASCII
  9.         _nop_();
  10.     _nop_();
  11.         SendByte(0);
  12.   }
  13. }
复制代码
回复

使用道具 举报

ID:836542 发表于 2021-1-11 17:03 | 显示全部楼层
回复

使用道具 举报

ID:824490 发表于 2021-1-11 17:06 | 显示全部楼层
595数据输出口在上电后是随机的,所以,你在上电后要做清除动作,即,送出0x00,多少个595就送多少个0x00
回复

使用道具 举报

ID:824490 发表于 2021-1-11 17:18 | 显示全部楼层
595的MR脚要接阻容复位或直接电源,OE要受控。你这电路不强壮。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

Powered by 单片机教程网

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