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

📄 evm_lcd.c

📁 pic18 of LCD source code
💻 C
字号:
//************************************************
//* 				evm_lcd.c					*
//************************************************
#include <delays.h>
#include "evm_lcd.h"

// For 10Mhz OSC Delay1KTCYx(4)=0.4ms
// Define us to Clockrate (MHz)
#ifndef OSC_CLOCK
#define OSC_CLOCK 10
#endif

//
// Definitions for I/O ports that provide LCD data & control
// PORTD[0:3]-->DB[4:7]: Higher order 4 lines data bus with bidirectional
//					  : DB7 can be used as a BUSY flag
// PORTE,0 --> [RS]: LCD Register Select control
// PORTE,1 --> [RW]: LCD Read/Write control
// PORTE,2 --> [E] : LCD operation start signal control 
//		      	   : "0" for Instrunction register (Write), Busy Flag (Read)
//				   : "1" for data register (Read/Write)
//
#define CPU_SPEED		OSC_CLOCK				// CPU speed is 16 Mhz !!
#define LCD_RS			PORTEbits.RE0	// The definition of control pins
#define LCD_RW			PORTEbits.RE1
#define LCD_E			PORTEbits.RE2
#define DIR_LCD_RS		TRISEbits.TRISE0
#define DIR_LCD_RW		TRISEbits.TRISE1
#define DIR_LCD_E		TRISEbits.TRISE2

#define LCD_DATA		LATD			// PORTD[4:7] as LCD DB[4:7]
#define DIR_LCD_DATA	TRISD	

//  LCD Module commands
#define DISP_2Line_8Bit	0b00111000
#define DISP_2Line_4Bit	0b00101000
#define DISP_ON			0x00C		// Display on
#define DISP_ON_C		0x00E		// Display on, Cursor on
#define DISP_ON_B		0x00F		// Display on, Cursor on, Blink cursor
#define DISP_OFF		0x008		// Display off
#define CLR_DISP		0x001		// Clear the Display
#define ENTRY_INC		0x006		//
#define ENTRY_INC_S		0x007		//
#define ENTRY_DEC		0x004		//
#define ENTRY_DEC_S		0x005		//
#define DD_RAM_ADDR		0x080		// Least Significant 7-bit are for address
#define DD_RAM_UL		0x080		// Upper Left coner of the Display	

#pragma udata
		
unsigned char 	Temp_CMD ;
unsigned char 	Str_Temp ;
unsigned char	Out_Mask ;

#pragma	code

// 

⌨️ 快捷键说明

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