打印

DS1302与LCD之间如何数据传输,函数调用?

[复制链接]
3413|15
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
razu_521|  楼主 | 2008-5-20 21:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我的LCD经过我的一番努力终于能调出显示啦!可是我的DS1302和LCD之间的数据传输,函数调用却出了问题!我现在就不懂LCD怎样才能读出DS1302的时钟数据?我的LCD是用并口的!请高手出招!!!!!!

相关帖子

沙发
jerkoh| | 2008-5-20 22:19 | 只看该作者

re

7个数据都读出来了,先看RAM中对否,对了
就查表送数据显示啊

使用特权

评论回复
板凳
ayb_ice| | 2008-5-21 08:39 | 只看该作者

DS1302与LCD之间能直接传递数据?

使用特权

评论回复
地板
xwj| | 2008-5-21 08:48 | 只看该作者

唉,??????????????

使用特权

评论回复
5
wegoinrain| | 2008-5-21 09:29 | 只看该作者

??

使用特权

评论回复
6
wswh2o| | 2008-5-21 09:30 | 只看该作者

lcd是自己调的?

使用特权

评论回复
7
computer00| | 2008-5-21 09:50 | 只看该作者

哈哈~~~刚好EDN的51实验板上有个DS1302,这两天刚好写了测试程

你这几天留意下我的blog吧,我会将整个测试程序发在我的BLOG上。
有LCD1602、DS18B20、DS1302、240x、UART、KEY、ADC0832等等驱动~~~~

使用特权

评论回复
8
winloop| | 2008-5-21 12:13 | 只看该作者

国人做假冒伪劣产品的本事在全世界是屈指可数的

使用特权

评论回复
9
农民讲习所| | 2008-5-21 12:51 | 只看该作者

DS1302驱动程序->接口数据->数据转换为字符串->调用LCD驱动程序显示

简单的LCD驱动程序:
一般包含:
  MoveTo(x,y)移动到指定位置
  DisplayStr(char *str)在当前位置显示字符串
  DisplayStr内部又调用更低层的DisplayChar( char c );

 DisplayChar( char c )实现又需要字模数据:一个2维数组Font[windth][height]。Font[windth]中每BIT代表一个象素点,一个字节代表8个点,12点宽度的话,高字节的高4位无效,一般=0。
  程序中依靠宽度、高度写进LCD中象素位置,

  完成。

使用特权

评论回复
10
razu_521|  楼主 | 2008-5-21 20:19 | 只看该作者

谢谢大家支招啦!

我把我的程序给大家看看,看我错到哪儿啦?谢谢啦!
#include <reg51.h>
#include <intrins.h>

#define uint8_t unsigned char
#define uint16_t unsigned int
#define nop()  _nop_()
#define DATA_PORT P0

void WriteCom(uint8_t CMD);
void WriteDat(uint8_t DAT);
void Delay(uint16_t ms);
uint8_t CheckBusy(void);
void Draw_Pic(uint8_t x, uint8_t y, char *Draw);
void Picture_Set_XY(uint8_t x, uint8_t y);
void Char_Set_XY(uint8_t x, uint8_t y, uint8_t *p);
void Lcd_Init(void);
void Set_Draw(void);

sbit RS = P2^0;
sbit RW = P2^1;
sbit EN = P2^2;
sbit sclk = P1^5;
sbit io = P1^6;
sbit reset = P1^7;

code uint8_t PIC1[64][16]={
/*--  --*/
/*--  宽度x高度=128x64  --*/
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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC1,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFC,0x00,0x00,0x3F,0xDF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0x0E,0x00,0x00,0x1F,0xCE,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0C,0x03,0xE0,0x00,0x07,0xFE,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x18,0x03,0x80,0x00,0x01,0xFE,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x00,0x10,0x02,0x40,0x00,0x00,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x00,0x10,0x00,0x40,0x00,0x00,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0xFF,0xF0,0x00,0x60,0x00,0x07,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x00,0x00,0x1E,0x60,0x00,0x0F,0xFC,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x00,0x00,0x63,0x70,0x00,0x0F,0x8C,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x00,0x00,0x41,0x40,0x00,0x0E,0x0E,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x00,0x00,0x41,0x40,0x00,0x06,0x0E,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x01,0xF0,0x41,0xE0,0x00,0x07,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x07,0x90,0x41,0xC0,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x1C,0x14,0x61,0x80,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x61,0xF0,0x1C,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0x00,0x0F,0xCC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x38,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,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,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,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,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,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,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x00,0x00,0x00,0x07,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xE0,0x00,0x00,0x00,0x03,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0x60,0x00,0x00,0x00,0x1F,0x98,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0x60,0x00,0x00,0x03,0xFF,0x4C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xF0,0x00,0x00,0x04,0xC1,0xC4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xF8,0x00,0x00,0x0E,0x3F,0xC1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0x9C,0x00,0x00,0x0B,0x69,0xC1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xEE,0x00,0x00,0x09,0x8F,0xC1,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xE7,0x00,0x06,0x18,0x8C,0x60,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xFB,0x80,0xFF,0xF9,0xD9,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xFD,0xC1,0x80,0x7F,0xFF,0xC0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xFE,0x71,0x00,0x18,0x7F,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x3F,0xFF,0x1F,0x00,0x00,0x1C,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0xFF,0xE1,0x00,0x19,0x70,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xFF,0xFF,0x80,0x31,0xE0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xFF,0xFF,0x80,0x24,0x38,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xFF,0xFF,0xC0,0x24,0x0E,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7F,0xFF,0xDE,0x3C,0x03,0xC3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x03,0xFF,0xFF,0xFC,0x00,0x66,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x07,0x80,0x3D,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x06,0xE0,0x0F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x07,0xB8,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x8E,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
code uint8_t PIC2[64][16]={
/*--  --*/
/*--  宽度x高度=128x64  --*/
0x00,0x00,0x00,0x04,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x1F,0x76,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3F,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x60,0xF8,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0xC0,0x39,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1C,0x80,0x19,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0x80,0x19,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x17,0x00,0x1B,0xC0,0x00,0x00,0x04,0x3C,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x00,0x1B,0xE0,0x00,0x00,0x0E,0x3F,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x0E,0x18,0xFC,0x00,0x00,0x0F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x1F,0x18,0xFF,0x00,0x00,0x03,0xF7,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x98,0xFF,0xE0,0x00,0x01,0xF3,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0xDE,0xFF,0xF8,0x00,0x00,0x7F,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xE0,0x5C,0xFF,0xFF,0x00,0x00,0x3F,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xE0,0x58,0xFF,0xFF,0xC0,0x00,0x07,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xE0,0x58,0x7F,0xFF,0xF8,0x07,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xE0,0x58,0xFF,0xFF,0xFE,0x0F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1C,0xE0,0x59,0xFF,0xFF,0xFE,0x0E,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1C,0xE0,0x5B,0xFF,0xFF,0xFE,0x0E,0x0C,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x70,0xD9,0xFF,0xFF,0xFC,0x0E,0x0C,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0x30,0xB1,0xFF,0xFF,0xFC,0x06,0x0C,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0x39,0xC0,0xFF,0xFF,0xF8,0x06,0x0C,0x70,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xBF,0x16,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF8,0x1F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x78,0x1F,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x08,0x0D,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x48,0x0C,0x3F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xC8,0x00,0x1F,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xC4,0x00,0x3F,0xFF,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xC0,0x00,0x3E,0x7F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xC0,0x00,0x3C,0x0F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x40,0x00,0x7C,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x40,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x40,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xC0,0x01,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x0C,0x00,0x07,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x1E,0x00,0x03,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xF0,0x03,0x73,0x00,0x01,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0xF0,0x03,0xE1,0x80,0x07,0xEC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xB0,0x03,0x80,0x81,0xDF,0xE6,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xF8,0x07,0xC0,0xC3,0x71,0xE3,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x07,0xFC,0x07,0xE0,0x63,0x0B,0xF1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xCE,0x03,0xB0,0x27,0x9A,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0F,0xF7,0x00,0x18,0x34,0xC7,0xF0,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xFB,0x80,0x0A,0x1C,0x67,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xFD,0xC0,0x3E,0x0C,0x66,0x30,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1F,0xFF,0xE0,0x66,0x0D,0xB9,0xE0,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x2F,0xFF,0xF8,0x83,0x06,0xFF,0xC0,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0xFF,0x9F,0x81,0x86,0x07,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0xFF,0xFF,0xC1,0x80,0x3E,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0xFF,0xFF,0xC0,0xC0,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0xFF,0xFF,0xE0,0xE0,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x71,0xFF,0xFF,0xE0,0x23,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x70,0x7F,0xFF,0xE0,0x06,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x70,0x03,0xFF,0xFF,0xFE,0x00,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x70,0x00,0x00,0x30,0x03,0xC0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x30,0x00,0x00,0x00,0x03,0xC0,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x30,0x00,0x00,0x00,0x03,0xC0,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x30,0x00,0x00,0x00,0x00,0xC0,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
/**************************************************/
void main()
{
 SP = 0X60;
 Delay(10);
 Lcd_Init();
 //Char_Set_XY(2,1,"初始化成功");
   Char_Set_XY(2,1);
   WriteDat("初始化成功");
     Delay(1000);
Lcd_Init();
     Delay(1000);
     Delay(1000);
 while(1)
 {

  //Char_Set_XY(0,0,"温度值:");

 // Char_Set_XY(0,1,"湿度值:");
  //Char_Set_XY(0,2,"日期:2008/6/10");
  // Char_Set_XY(3,3,"14点15分");
  Delay(1000);
  Delay(1000);
  Delay(1000);
  Delay(1000);
  Delay(1000);
  Set_Draw();
  Draw_Pic(0,0,*PIC1);
  Delay(1000);
  Draw_Pic(0,0,*PIC2);
  Delay(1000);
  //Delay(1000);
  //Delay(1000);
  Lcd_Init();
  //Char_Set_XY(2,2,"欢迎使用");
  //for(;);

 }
}
/*****************初始化********************************/
void Lcd_Init(void)
{
 uint8_t cmd;
  cmd=0x30;   //功能设置 8位数据,基本指令
 WriteCom(cmd);  //写指令
 cmd=0x0C;   //显示状态 ON,游标OFF,反白OFF
 WriteCom(cmd);  //写指令
 cmd=0x01;   //清除显示
 WriteCom(cmd);  //写指令
 cmd=0x02;   //地址归位
 WriteCom(cmd);  //写指令
 cmd=0x80;   //设置DDRAM地址
 WriteCom(cmd);  //写指令
 Delay(100);   //延时
}
/*****************延时********************************/
void Delay(uint16_t ms)
{
    uint8_t j;
    for(; ms>0; ms--)
     for(j=100; j>0; j--)
  {
    nop();
   nop();
  }
}
/***************写指令**********************************/
void WriteCom(uint8_t CMD)
{
 while(CheckBusy());
 RS = 0;
 RW = 0;
 DATA_PORT = CMD;
 EN = 1;
 nop();
 nop();
 EN = 0;
}
/***************写数据**********************************/
void WriteDat(uint8_t DAT)
{
 while(CheckBusy());
 RS = 1;
 RW = 0;
 DATA_PORT = DAT;
 EN = 1;
 nop();
 nop();
 EN = 0;
}
/******************监测忙碌*******************************/
uint8_t CheckBusy(void)
{
 uint8_t temp;
 DATA_PORT = 0XFF;
 RS = 0;
 RW = 1;
 EN = 1;
 nop();
 nop();
 temp = DATA_PORT;
 nop();
 nop();
 EN = 0;
 temp &= 0x80;
 return(temp);
}
/*****************设置汉字位置********************************/
void Char_Set_XY(uint8_t x, uint8_t y, uint8_t *p)
{
   if(y == 0)
 {
   WriteCom((0x80+x));
 }
 if(y == 1)
 {
  WriteCom((0x90+x));
 }
 if(y == 2)
 {
  WriteCom((0x88+x));
 }
 if(y == 3)
 {
  WriteCom((0x98+x));
 }
 while(*p != 0)
 {
  WriteDat(*p++);
 }
}

/*****************设置图形********************************/
void Set_Draw(void)
{
 WriteCom(0x01);     //清屏
 Delay(100);    //延时
 WriteCom(0x36);   //8BIT控制界面,扩充指令集,,绘图显示ON
 Delay(100);    //延时
}
/******************设置图形坐标*******************************/
void Draw_Pic(uint8_t x, uint8_t y,uint8_t *Draw)
{
 uint8_t i, j, temp_x, temp_y;
 temp_x = x;
 temp_y = y;
 temp_x |= 0x80;
 temp_y |= 0x80;
 for(i=0;i<32;i++ )
 {
  WriteCom(temp_y++);   //设置绘图区的Y地址坐标
  WriteCom(temp_x);   //设置绘图区的X地址坐标
  for(j=0;j<16;j++)
  {
    WriteDat(*Draw);
    Draw++;
  }
 }
 temp_x = 0x88;
 temp_y = 0x80;
 j = 0;
 for(;i<64;i++ )
 {
  WriteCom(temp_y++);   //设置绘图区的Y地址坐标
  WriteCom(temp_x);   //设置绘图区的X地址坐标
  for(j=0;j<16;j++)
  {
    WriteDat(*Draw);
    Draw++;
  }
 }

}
/**************************************************/
//------------液晶模块结束---------------------


//-----------ds1302模块开始-------------------
//注意点:sclk的上升沿输入数据,sclk的下跳沿输出数据
//读写时都是从第0位开始
void write_byte(uint8_t inbyte)
{
uint8_t i;
for(i=8;i>0;i--)
{
  sclk=0;   //写的时候低电平改变数据
  if(inbyte&0x01)
      io=1;
  else
      io=0;
  sclk=1;  //写的时候高电平,把数据写入ds1302
  _nop_();
  inbyte=inbyte>>1;
}
}
uint8_t read_byte() //sclk的下跳沿读数据
{
uint8_t i,temp=0;
io=1;          //设置为输入口
for(i=7;i>0;i--)
{
   sclk=0;
   if(io==1)
   temp=temp|0x80;
   else
   temp=temp&0x7f;
   sclk=1;       //产生下跳沿
   temp=temp>>1;
}
return (temp);
}
//----------往ds1302的某个地址写入数据-------------
void write_ds1302(uint8_t cmd,uint8_t indata)
{
  reset=1;
  write_byte(cmd);
  write_byte(indata);
  reset=0;
  sclk=0;
}
//----------读ds1302某地址的的数据-----------------
uint8_t read_ds1302(uint8_t addr)
{
uint8_t backdata;
reset=1;
write_byte(addr);
backdata=read_byte();//先写地址,然后读数据
reset=0;
sclk=0;
return (backdata);
}
//------------设置初始时间-------------------
void set_ds1302(uint8_t addr,uint8_t *p,uint8_t n)//写入n个数据
{
  write_ds1302(0x8e,0x00);//写控制字,允许写操作
  for(;n>0;n--)
  {write_ds1302(addr,*p);
   p++;
   addr=addr+2;
  }
  write_ds1302(0x8e,0x80);//写保护,不允许写
}
//----------- 读取当前时间-------------------
void read_nowtime(uint8_t addr,uint8_t *p,uint8_t n)
{
for(;n>0;n--)
{
   *p=read_ds1302(addr);
   p++;
   addr=addr+2;
}
}
void init_ds1302()
{
  reset=0;
  sclk=0;
  write_ds1302(0x80,0x00);//写控制字,允许写
  write_ds1302(0x90,0x00);//禁止涡流充电
}
//-----------ds1302模块结束-------------------//

使用特权

评论回复
11
razu_521|  楼主 | 2008-5-21 20:21 | 只看该作者

DS1302与LCD之间如何数据传输,函数调用?

还有请高手给写个主程序啦!!!!谢谢啦!

使用特权

评论回复
12
computer00| | 2008-5-22 11:20 | 只看该作者

去我的BLOG下载我的程序吧...在time.c里面。

使用特权

评论回复
13
gyt| | 2008-5-22 15:08 | 只看该作者

很有意思

使用特权

评论回复
14
dandywang| | 2008-5-23 09:08 | 只看该作者

DS1302与LCD之间可以直接数据传送?

不通过mcu?

使用特权

评论回复
15
ad3600| | 2011-5-13 21:53 | 只看该作者
请问那DS1302已经启动,且读出的时钟数据正常,但我希望在半途中改变现有时间,比如用按键1,每按一下键位,那分钟位就上调一分钟,那该怎么去弄程序???

使用特权

评论回复
16
ad3600| | 2011-5-13 21:54 | 只看该作者
麻烦有招的童靴发去我邮箱~!
879616923@qq.com
谢谢~!!~

使用特权

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

本版积分规则

11

主题

29

帖子

0

粉丝