打印

关于lcd1602显示问题

[复制链接]
2323|10
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hllyellow|  楼主 | 2012-9-2 16:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
beethuhong| | 2012-9-2 16:23 | 只看该作者
地址弄正确了没?..第二行首地址弄正确。

使用特权

评论回复
板凳
hllyellow|  楼主 | 2012-9-2 18:58 | 只看该作者
第二行是从oxc0开始的呀

使用特权

评论回复
地板
duhemayi| | 2012-9-2 19:06 | 只看该作者
网速问题,看不到?你用的是哪个厂家的?

使用特权

评论回复
5
duhemayi| | 2012-9-2 19:14 | 只看该作者
把程序贴出来看下,应该是地址问题!

使用特权

评论回复
6
hllyellow|  楼主 | 2012-9-2 19:58 | 只看该作者
main.rar (819 Bytes) 主程序

使用特权

评论回复
7
hllyellow|  楼主 | 2012-9-2 20:11 | 只看该作者
#include<reg52.h>
#include<intrins.h>
#include"ds1302.h"
#include"delay.h"
#include"lcd1602.h"

uchar code table1[]="0123456789-:";

void ds1302_init()
{
  write_ds1302(0x8e,0x00);//禁止写保护
  write_ds1302(0x80,0x00);//写秒
  write_ds1302(0x82,0x00);//写分
  write_ds1302(0x84,0x00);//写时
  write_ds1302(0x86,0x31);//写日
  write_ds1302(0x88,0x08);//写月
  write_ds1302(0x8a,0x02);//写周
  write_ds1302(0x8c,0x12);//写年
  write_ds1302(0x8e,0x80);//允许写保护
  
}





void main()
{


uchar t_sec,sec1,sec2;
uchar t_min,min1,min2;
uchar t_hr,hr1,hr2;
uchar t_mon,mon1,mon2;
uchar t_date,date1,date2;
uchar t_year,year1,year2;
uchar t_day,day1;

LCD_init();
delayus(5);

ds1302_init();
delayus(5);



while(1)
{
  t_sec=read_ds1302(0x81);//读秒寄存器
  sec1=t_sec&0x0f;
  sec2=(t_sec>>4);

  t_min=read_ds1302(0x83);//读分寄存器
  min1=t_min&0x0f;
  min2=(t_min>>4);

  t_hr=read_ds1302(0x85);//读时寄存器
  hr1=t_hr&0x0f;
  hr2=(t_hr>>4);

  t_date=read_ds1302(0x87);//读日寄存器
  date1=t_date&0x0f;
  date2=(t_date>>4);

  t_mon=read_ds1302(0x89);//读月寄存器
  mon1=t_mon&0x0f;
  mon2=(t_mon>>4);

  t_day=read_ds1302(0x8b);//读星期寄存器
  day1=t_day&0x0f;
  //day2=(t_day>>4);

  t_year=read_ds1302(0x8d);//读年寄存器
  year1=t_year&0x0f;
  year2=(t_year>>4);

  LCD_write_com(0x80);
  LCD_write_Data(table1[2]);

  LCD_write_com(0x81);
  LCD_write_Data(table1[0]);

  LCD_write_com(0x82);//写年寄存器
  LCD_write_Data(table1[year2]);

  LCD_write_com(0x83);
  LCD_write_Data(table1[year1]);
  
  LCD_write_com(0x84);
  LCD_write_Data(table1[10]);

  LCD_write_com(0x85);//写月寄存器
  LCD_write_Data(table1[mon2]);

  LCD_write_com(0x86);
  LCD_write_Data(table1[mon1]);
   
  LCD_write_com(0x87);
  LCD_write_Data(table1[10]);

  LCD_write_com(0x88);//写日寄存器
  LCD_write_Data(table1[date2]);

  LCD_write_com(0x89);
  LCD_write_Data(table1[date1]);  

  LCD_write_com(0x80+0x40);//写时寄存器
  LCD_write_Data(table1[hr2]);

  LCD_write_com(0xc1);
  LCD_write_Data(table1[hr1]);
   
  LCD_write_com(0xc2);
  LCD_write_Data(':');

  LCD_write_com(0xc3);//写分寄存器
  LCD_write_Data(table1[min2]);

  LCD_write_com(0xc4);
  LCD_write_Data(table1[min1]);

  LCD_write_com(0xc5);
  LCD_write_Data(table1[11]);

  LCD_write_com(0xc6);//写秒寄存器
  LCD_write_Data(table1[sec2]);

  LCD_write_com(0xc7);
  LCD_write_Data(table1[sec1]);

  LCD_write_str(9,1,"week=");

  LCD_write_com(0xce);//写星期寄存器
  LCD_write_Data(table1[day1]);

  

  







  

  
  



}



}

使用特权

评论回复
8
joyme| | 2012-9-3 10:18 | 只看该作者
填6个空格试试

使用特权

评论回复
9
hllyellow|  楼主 | 2012-9-3 11:43 | 只看该作者
谢谢,为什么会出现这种现象呢,按程序来走应该是第二行日期后面的时间是不应该显示的

使用特权

评论回复
10
zuanze| | 2012-9-3 11:57 | 只看该作者
是不是你写字符的循环位数没有控制好呢?

使用特权

评论回复
11
hllyellow|  楼主 | 2012-9-3 20:44 | 只看该作者
谢谢各位大侠,问题已解决,是控制字子函数出了点问题。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

18

帖子

1

粉丝