×
嵌入式 > 嵌入式开发 > 详情

基于C8051F的金鹏LCD19264(带字库)程序

发布时间:2020-08-26 发布时间:
|
//-------------------------------------------------------------------------*

//文件名: LCD.h (LCD头文件) *
//-------------------------------------------------------------------------*
#include "C8051F340.h"
#include
#define uint unsigned int
#define uchar unsigned char

 bit rw = P2^1; //H=read; L=write;

//sbit e1 = P2^2; //up input enable;
sbit e2 = P2^2; //down input enable;
sbit rs = P2^0; //H=data; L=command;
//sbit rst= P3^0; //Reset Signal 低电平有效
void init_lcd ();
void clrram ();
void string_disp (uchar up,uchar down,uchar addr,uchar length,uchar code *pp); //显示字符串
void number_disp (uchar up,uchar down,uchar addr,uchar length,uchar number1,uchar number2); //显示数字

//up:上半屏 down:下半屏
//up为1,控制上半屏,down为1,控制下半屏
uchar Math_Subwith(uchar dat) //线序反转
{
uchar i,temp;
temp = 0x00;
for(i=0;i<8;i++)
{
temp >>= 1;
if((dat< {
temp |= 0x80;
}
else
{
temp &= 0x7F;
}
}
return temp;
}
//*******************************
//判忙
//*******************************
void chk_busy (uchar up,uchar down)
{
if(up==1)
{
P1 = Math_Subwith(0xff);
rs=0;
rw=1;
//e1=1;
P4 = P4|0x01;
while(P1 & 0x01);
//e1=0;
_nop_();_nop_();_nop_();_nop_();
P4 = P4&0xfe;
}
if(down==1)
{
P1 =Math_Subwith(0xff);
rs=0;
rw=1;
e2=1;
while(P1& 0x01);
_nop_();_nop_();_nop_();_nop_();
e2=0;
}
}
//********************************************
//写命令
//********************************************
void send_c (uchar up,uchar down,uchar comm)
{
chk_busy (up,down);
rs=0; //command
rw=0; //write
if(up==1)
{
P1 = Math_Subwith(comm); //output comm
//e1=1;
P4 = P4|0x01;
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
//e1=0;
P4 = P4&0xfe;
}
if(down==1)
{
P1 = Math_Subwith(comm); //output comm
e2=1;
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
e2=0;
}
}



『本文转载自网络,版权归原作者所有,如有侵权请联系删除』

热门文章 更多
NXP推出Wi-Fi 6E三频段SOC 充分释放6GHz频谱潜力