⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd12864.h

📁 12位的数字电位器,在参加电子设计大赛的时候用的.
💻 H
字号:
#ifndef _LCD12864_H
#define _LCD12864_H
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int

/**********I/O口定义**********/
#define LCD_DB P0
sbit LCD_RS  = P1^0;
sbit LCD_RW  = P1^1;
sbit LCD_E   = P3^4;
sbit LCD_RST = P1^7;
sbit int_0	 = P3^2;

/*********************************************************** 
函数名称:delayms
函数功能:延时n ms
入口参数:无
出口参数:无
备    注:无
***********************************************************/ 
void delayms(uint n)
{
  uint j;
  while(n--)
	 for(j=0;j<2327;j++)
	    _nop_();
}

/*********************************************************** 
函数名称:lcd_ready
函数功能:LCD读忙
入口参数:无
出口参数:无
备    注:执行时间:0μs
***********************************************************/ 
void lcd_ready(void)
{
 LCD_DB = 0xFF; 

 LCD_RW = 1;
 LCD_RS = 0;
 LCD_E  = 1;
 while (LCD_DB&0x80) ;
 LCD_E  = 0;
} 

/*********************************************************** 
函数名称:send_command
函数功能:向LCD发送指令
入口参数:uchar Command 
出口参数:无
备    注:执行时间:72μs
***********************************************************/ 
void send_command(uchar Command)
{
 lcd_ready();
 
 LCD_RW = 0;
 LCD_RS = 0;
 LCD_DB = Command;
 LCD_E  = 1;
 _nop_();
 _nop_();
 LCD_E  = 0;
} 

/*********************************************************** 
函数名称:send_data
函数功能:向LCD发送数据
入口参数:uchar Data
出口参数:无
备    注:执行时间:72μs
***********************************************************/ 
void send_data(uchar Data)
{
 lcd_ready(); 

 LCD_RW = 0;
 LCD_RS = 1;
 LCD_DB = Data;
 LCD_E  = 1;
 _nop_();
 _nop_();
 LCD_E  = 0;
} 

/*********************************************************** 
函数名称:lni_lcd
函数功能:LCD初始化
入口参数:无
出口参数:无
备    注:无
***********************************************************/ 
void lni_lcd(void)
{
 LCD_RST = 0;
 delayms(20);
 LCD_RST = 1;
 _nop_();
 send_command(0x34);
 send_command(0x30);
 send_command(0x01);
 send_command(0x06); 
 send_command(0x0C); //显示状态:开,执行时间:72μs//
} 
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -