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

📄 lcd_el16032.c

📁 how to use display EL16032
💻 C
字号:
/***********************************************************************
 *                                                                     *
 *      Project Name:   Demo board for graphic LCD EL 16032            *
 *      Description:    											   *
 *                                                                     *
 *      Processor:      uPD78F9177                                     *
 *      Revision:       1.0                                            *
 *      Date:           08.12.2003                                     *
 *      Compiler:       C crosscompiler IAR 2.22                       *
 *      Author:                                            *
 *      Company:     	                                                   *
 *      Email:              			                          *
 *                                                             		        *
 ***********************************************************************/
#include <in78000.h>
#include "Df9177ay.H"
#include "appcfg.h"
#include "LCD_el16032.h"
bit bFlag;
unsigned char j;
// check of status bit 
void busy_check(void)
{
	  unsigned char Counter = 0xFF;
	  PM5 = 0xFF;     // set port to input
	//  PM0 = 0xFF;		// set port to input
	  do
	  {
		    RW = 1;              // Set Read 
		    RS = 0;             // Set command
		    E = 1;              // set enable
		    E1 = 1;              // set enable
		    for(j=0; j < 10; j++) _NOP();
		    bFlag = P5.3;       // Read status bit
		    E = 0;
		    E1 = 0;              
		    for(j=0; j < 10; j++) _NOP();             
		    Counter --; 
	  }while(bFlag && Counter);       // wait for Status bit = 0
	  RW = 0;               
	  PM5 = 0xF0;            // set Port to output
	  PM0 = 0xC0;			// set port to output 
}

// write command to LCD
void lcd_write_cmd_bc(unsigned char Lcd_data)
{
    RS = 0;								// set commnad mode
	RW = 0;								// set write mode
	P0 &= 0xF0;
	P0 |= (Lcd_data & 0x0F);			// low byte of data to port P0
	P5 = Lcd_data >> 4;                 // high byte of data to port P5
  	E = 1;								// enable to 1
  	E1 = 1;              				// set enable
	for (j = 0; j < 10; j++) _NOP();		// wait 2us
	E = 0;								//	enable to 0
	E1 = 0;
}

// write command to LCD
void lcd_write_cmd(unsigned char Lcd_data)
{
    busy_check();
    RS = 0;								// set commnad mode
	RW = 0;								// set write mode
	P0 &= 0xF0;
	P0 |= (Lcd_data & 0x0F);			// low byte of data to port P0
	P5 = Lcd_data >> 4;                 // high byte of data to port P5
  	E = 1;								// enable to 1
  	E1 = 1;              // set enable
	for (j = 0; j < 10; j++) _NOP();		// wait 2us
	E = 0;								//	enable to 0
	E1 = 0;
    for( j=0; j < 0xFF; j++) _NOP();
}

// write data  to LCD
void lcd_write_data (unsigned char Lcd_data)
{
    busy_check();
    RS = 1;								// set commnad mode
	RW = 0;								// set write mode
	P0 &= 0xF0;
	P0 |= (Lcd_data & 0x0F);			// low byte of data to port P0
	P5 = Lcd_data >> 4;                 // high byte of data to port P5
  	E = 1;								// enable to 1
  	E1 = 1;              // set enable
	for(j = 0; j < 10; j++) _NOP();		// wait 2us
	E = 0;								//	enable to 0
	E1 = 0;
    for(j = 0; j < 0xFF; j++) _NOP();
}
// initializing of display
void lcd_init (unsigned char Mod)
{
	  delay(50);                         	// wait 50ms
	  lcd_write_cmd_bc(0x30);               //initialize only
	  delay(10);                         	// wait 10ms
	  lcd_write_cmd_bc(0x30);               //initialize only
	  delay(1);                         	// wait 10ms
	  lcd_write_cmd_bc(0x30);               //initialize only
	  switch (Mod)
	  {
	  	case 0:lcd_write_cmd(0x3c);break;                  //mode: 8-bit and 1:4 
	  	case 1:lcd_write_cmd(0x3E);break;                  //mode: Graphic is ON
	  }
	  lcd_write_cmd(LCD_OFF);               //LCD Off
	  lcd_write_cmd(LCD_CLR);               //Clear LCD
	  delay(3);								// wait 3 ms
	  lcd_write_cmd(INCDD_CG_SHF_C);        // autoincrement and cusrsor shift to right
	  lcd_write_cmd(CURSOR_HOME);            // set cursor to home
	  lcd_write_cmd(LCD_ON);           		// Display ON
}

void lcd_text(unsigned char *pText)
{
	//_DI();
	while (*pText != 0x00)
	{
		lcd_write_data(*pText);
		pText++;
	}
	//_EI();
}

void lcd_clear_graf(void)
{
	unsigned char Col;
	char Row;
	lcd_write_cmd(0x3E);
	lcd_write_cmd(ROW_ENABLE);
	for (Row = 0x80; Row < 0xA0;Row++)
	{
		for (Col = 0x80; Col < 0x8A; Col++)
		{
			lcd_write_cmd(Row);
			lcd_write_cmd(Col);
			lcd_write_data(0x00);
			lcd_write_data(0x00);
		}
		
	}
}

⌨️ 快捷键说明

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