找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1108|回复: 1
打印 上一主题 下一主题
收起左侧

ds12887仿真显示为什么不走 求帮助

[复制链接]
跳转到指定楼层
楼主
ID:591930 发表于 2021-3-9 13:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit e=P2^0;
sbit rw=P2^1;
sbit rs=P2^2;
sbit sas=P2^6;
sbit srw=P3^6;
sbit scs=P2^7;
sbit sds=P3^7;
uchar fen,shi,miao;
void yanshi(uint x)
{
        uchar y,s;
        for(y=x;y>0;y--)
        for(s=110;s>0;s--);
}
void zhiling(uchar x)
{
        rs=0;
        rw=0;
        e=0;
        P1=x;
        yanshi(5);
        e=1;
        yanshi(5);
        e=0;
}
void shuju(uchar x)
{
        rs=1;
        rw=0;
        e=0;
        P1=x;
        yanshi(5);
        e=1;
        yanshi(5);
        e=0;
}
void chushi()
{
        zhiling(0x38);
        zhiling(0x0c);
        zhiling(0x06);
        zhiling(0x80);
        zhiling(0x01);
        zhiling(0x80+0x40+11);
        shuju(':');        
        zhiling(0x80+0x40+8);
        shuju(':');               
                                
}
void msf(uchar x,y)
{
        uchar ge,shi;
        ge=x%10;
        shi=x/10;
        zhiling(0x80+0x40+y);
        shuju(0x30+shi);
        shuju(0x30+ge);
}
void xieshi(uchar x,y)//写ds12887
{
        scs=0;
        srw=1;
        sds=1;
        sas=1;
        P0=x;
        sas=0;
        srw=0;
        P0=y;
        srw=1;
        sas=1;
        scs=1;

}
uchar dushi(uchar x)  //读12887
{                                 
        uchar y;
        scs=0;
        srw=1;
        sds=1;
        
        sas=1;
        P0=x;
        sas=0;
        sds=0;
        P0=0xff;
        y=P0;
        sds=1;
        sas=1;
        scs=1;
        return y;               
}

void main()
{
        chushi();
        xieshi(0x0b,0x02);
        xieshi(0x0a,0x20);
        while(1)
        {
                miao=dushi(0);
                fen=dushi(2);
                shi=dushi(4);
                msf(miao,12);        
                msf(fen,9);            
                msf(shi,6);

        }
}                                          

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:591930 发表于 2021-3-9 13:53 | 只看该作者
小弟选谢谢了,
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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