找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

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

[复制链接]
admin 发表于 2012-9-3 02:38:29 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
我把我的程序给大家看看,看我错到哪儿啦?帮我改改主程序啦!谢谢啦!
#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,
 楼主| admin 发表于 2012-9-3 02:38:32 | 显示全部楼层
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模块结束-------------------//
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-12-23 21:49 , Processed in 0.051465 second(s), 8 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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