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

📄 lcd.c

📁 主要介绍了24c16的读写,mcu为89s52,lcd为TC2002A,完成功能是把数据写入24c16中,再把数据从24c16读出,并显示在lcd中.编辑环境为keil2,已通过测试.
💻 C
字号:

#include<reg52.h>
#include"port.h"
#include"main.h"
#include"lcd.h"
#include"delay.h"
#include<intrins.h>

void SHIFT(uChar dispdata)
{         
	uChar i,j;
	DISSP = 0;                    //define variable
	j = dispdata;
	for(i=0; i<8; i++)               //write 8 bit
	{
		if((j & 0x80) == 0)
		{
			SOUT = 0;        
		}		                //get the highest bit   
		else
		{		
			SOUT = 1;	
		}
		SCK = 0;
		SCK = 1;
		SCK = 0;
		j <<= 1;                   //move left wrTemp one bit 
	}
	DISSP = 1;
}

void LCD_WCOM(uChar dispdata)   
{   

	SHIFT(dispdata);
	LCD_RS = 0 ;
	LCD_E = 1;    
	LCD_E = 0;
	DELAY(40);
}

void LCD_WDATA(uChar dispdata)
{   

	SHIFT(dispdata);
	LCD_RS = 1;
	LCD_E = 1;    
	LCD_E = 0; 
	DELAY(1);
}

void LCD_INIT(void)
{
    DELAY(40);
	
	LCD_WCOM(0x38); //0x01
	LCD_WCOM(0x38);//0x30 8位 
	LCD_WCOM(0x38); 
	LCD_WCOM(0x38);
	LCD_WCOM(0x06);//0x0c
	LCD_WCOM(0x0c);
	LCD_WCOM(0x01);
}
uChar LCD_DISP(uChar *ptr_Char, uChar postion, uChar num) //num From 0 ~1 post from 0~7
{
	uChar i;
	if ((postion >= 101) && ( postion <= 120))         //第一行  自定义101~120    100 < post < 121 
	{	
		LCD_WCOM(0x80 + postion -101); 
	}
	else if((postion >= 201) && (postion <= 220))	   //第二行 自定义201~220         200 < post < 221
		{
			LCD_WCOM(0xc0 + postion -201) ;
		}
		else if(postion != 0)
		{
			return ERROR;                                  //不在范围

⌨️ 快捷键说明

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