📄 initlcd.c
字号:
/*********************************************************************
*Description: SW680GAM Machine LCD INITIAL Drive Program
*File Name: LCD.C
*Use Compile Lanague: KEIL C51
*Version : V1.0
*Code Author: zhouhuanxi
*Date: 2005-01-14
CopyRight(C) 2005 -- SHENZHEN XINSANWEI Machine&Electronics CO.,LTD.
*********************************************************************/
//==== FILE Include And Macro Declare Segment====
#include "Config.H"
//-----------------------------------------------
//LCD Working Status Check MARCO(Busy or Ready)
#define LcdWaitBusy() \
LCD_DATA=0xFF; \
LCD_DI = 0; \
LCD_RW = 1; \
LCD_E = 1; \
_NOP_(); \
LCD_E = 0; \
while (LCD_DATA &0x7F ==0x80);
//*************************************************
//============ FUNCTION CODE SEGMENT =============
//*************************************************
//=================================================
//Function: InitLcd
//Description: Init LCD
//Parameters: NO.
//Call: SingleCmd()
//Returns: NO.
//Side Effects: NO.
//=================================================
void InitLcd(void)
{
LCD_DATA = 0x00;
LCD_DI = 0;
LCD_RW = 0;
LCD_E = 0;
LCD_CS1 = 0;
LCD_CS2 = 0;
SingleCmd(DISPLAY_OFF); //Display OFF
SingleCmd(START_LINE);
SingleCmd(X_ADRESS);
SingleCmd(Y_ADRESS);
SingleCmd(DISPLAY_ON); // Display ON
}
//=================================================
//Function: SingleData
//Description: Only Send a Byte of Data to LCD
//Parameters: col,c
//col ---- Display col Address
//c ---- Diaplay Content
//Call: _NOP_()
//Returns: NO.
//Side Effects: NO.
//=================================================
void SingleData(uint8 col,uint8 c)
{
LCD_E=0;
LCD_DI=0;
LCD_RW=1;
if(col<64)
{
LCD_CS1=1;
}
else
{
LCD_CS2=1;
}
LcdWaitBusy();
LCD_DI = 1; // Data mode
LCD_RW = 0; // write mode
LCD_DATA = c; // outbyte
_NOP_();
LCD_E = 1; // Strobe
_NOP_();
LCD_E = 0;
_NOP_();
_NOP_();
LCD_CS1=0;
LCD_CS2=0;
}
//=================================================
//Function: SingleCmd
//Description: Only Send a Byte of Command Data to LCD,Set LCD's Status
//Parameters: c
//c ---- LCD Control Command (uint8)
//Call: _NOP_(),LcdWaitBusy()
//Returns: NO.
//Side Effects: NO.
//=================================================
void SingleCmd(uint8 c)
{
LCD_E=0;
LCD_DI=0;
LCD_RW=1;
LCD_CS1=1;
LCD_CS2=1;
LcdWaitBusy();
LCD_DI = 0; // Instruction mode
LCD_RW = 0; // Write mode
//LCD_E = 1; // Strobe
//_NOP_();
//LCD_E = 0;
//_NOP_();
LCD_DATA = c; // outbyte
_NOP_();
_NOP_();
LCD_E = 1;
_NOP_();
_NOP_();
LCD_E = 0;
_NOP_();
_NOP_();
LCD_CS1=0;
LCD_CS2=0;
}
/************************************************************************************************************
***************************************** END OF FILE *******************************************************
************************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -