没有合适的资源?快使用搜索试试~ 我知道了~
12864液晶屏显示
需积分: 10 2 下载量 5 浏览量
2014-09-19
06:01:05
上传
评论
收藏 5KB TXT 举报
温馨提示
试读
7页
简单的52单片机控制液晶屏显示,并行口输入。
资源推荐
资源详情
资源评论
#include<reg52.h>
#include <math.h>
void lcd_init(void);
void clr_lcd(void);
void send_com(unsigned char cmd);
void send_data(unsigned char dat);
void chek_busy(void);
void set_xy(unsigned char xpos,unsigned char ypos);
void print(unsigned char x,unsigned char y,char* str);
void printstr(unsigned char xpos,unsigned char ypos,unsigned char str[],unsigned char k);
unsigned char code dis1[]={"111111"};//欢迎
unsigned char code dis2[]={"222222"};//
unsigned char code dis3[]={"33333"};//
unsigned char code dis4[]={"444444"};//
sbit key=P0^0;
#define DATA P1 //P2接数据口
#define CONTROL P0
#define E 7 //并行的使能信号 sbit E = P0^7
#define RW 6 //并行的读写信号 sbit RW = P0^6
#define RS 5 //并行的指令数据选择信号 sbit RS = P0^5
#define PSB 4 //并/串行接口选择 sbit PSB = P0^4
#define RST 3 //复位 低电平有效 sbit RST = P0^3
#define SETB(x,y) (x|=(1<<y)) //设置第x位为1
#define CLRB(x,y) (x&=(~(1<<y))) //设置第x位为0
#include <math.h>
void lcd_init(void);
void clr_lcd(void);
void send_com(unsigned char cmd);
void send_data(unsigned char dat);
void chek_busy(void);
void set_xy(unsigned char xpos,unsigned char ypos);
void print(unsigned char x,unsigned char y,char* str);
void printstr(unsigned char xpos,unsigned char ypos,unsigned char str[],unsigned char k);
unsigned char code dis1[]={"111111"};//欢迎
unsigned char code dis2[]={"222222"};//
unsigned char code dis3[]={"33333"};//
unsigned char code dis4[]={"444444"};//
sbit key=P0^0;
#define DATA P1 //P2接数据口
#define CONTROL P0
#define E 7 //并行的使能信号 sbit E = P0^7
#define RW 6 //并行的读写信号 sbit RW = P0^6
#define RS 5 //并行的指令数据选择信号 sbit RS = P0^5
#define PSB 4 //并/串行接口选择 sbit PSB = P0^4
#define RST 3 //复位 低电平有效 sbit RST = P0^3
#define SETB(x,y) (x|=(1<<y)) //设置第x位为1
#define CLRB(x,y) (x&=(~(1<<y))) //设置第x位为0
#define CHKB(x,y) (x&(1<<y))
/********************测忙碌**********************/
//测忙碌子程序
//RS=0,RW=1,E=H,D0-D7=状态字
/************************************************/
void chek_busy(void)
{ unsigned char temp1;//状态信息(判断是否忙)
CLRB(CONTROL,RS); // RS = 0;
SETB(CONTROL,RW); // RW = 1;
SETB(CONTROL,E); // E = 1;
do{temp1 = DATA;DATA=0xFF;} while(temp1&0x80);//??????
SETB(CONTROL,E); // E = 1;
DATA=0xFF;
}
/********************写命令**********************/
//写命令子程序
//
/************************************************/
void send_com(unsigned char cmd)/*写命令*/
{
chek_busy();
CLRB(CONTROL,RS); //RS = 0;
CLRB(CONTROL,RW); //RW = 0;
DATA = cmd;
SETB(CONTROL,E); //E = 1;
CLRB(CONTROL,E); //E = 0;
}
/********************写数据**********************/
/********************测忙碌**********************/
//测忙碌子程序
//RS=0,RW=1,E=H,D0-D7=状态字
/************************************************/
void chek_busy(void)
{ unsigned char temp1;//状态信息(判断是否忙)
CLRB(CONTROL,RS); // RS = 0;
SETB(CONTROL,RW); // RW = 1;
SETB(CONTROL,E); // E = 1;
do{temp1 = DATA;DATA=0xFF;} while(temp1&0x80);//??????
SETB(CONTROL,E); // E = 1;
DATA=0xFF;
}
/********************写命令**********************/
//写命令子程序
//
/************************************************/
void send_com(unsigned char cmd)/*写命令*/
{
chek_busy();
CLRB(CONTROL,RS); //RS = 0;
CLRB(CONTROL,RW); //RW = 0;
DATA = cmd;
SETB(CONTROL,E); //E = 1;
CLRB(CONTROL,E); //E = 0;
}
/********************写数据**********************/
剩余6页未读,继续阅读
资源评论
liuhei05
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功