您的位置 首页 测评

克己51单片机常用头文件(T6963C)

#includereg51.h#defineuintunsignedint#defineucharunsignedcharcodeucharCCTAB[1024]={/*–宽度x高度=128×64-

#include “reg51.h”

#define uint unsigned int
#define uchar unsigned char

code uchar CCTAB [1024]={
/*– 宽度x高度=128×64 –*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xF0,0x00,0x00,0x15,0x2A,0x00,0x00,0xF0,0x00,0x00,0xA8,0xA0,0x00,0x7C,0x00,
0x00,0xF0,0x00,0x00,0x00,0x55,0x00,0x03,0xC0,0x1F,0x00,0x54,0x00,0x00,0x7C,0x00,
0x00,0xF1,0xFF,0xFF,0x94,0xAA,0x0F,0xC7,0x80,0x11,0x80,0xA8,0xA9,0xFC,0x7C,0x00,
0x00,0xF3,0xFF,0xFF,0xA8,0x55,0x03,0xFF,0xF8,0x60,0xC0,0x51,0x54,0xFE,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x14,0xAA,0x0F,0xFF,0xC0,0xDC,0x40,0x02,0xAA,0x06,0x7C,0x00,
0x00,0xF2,0x01,0x40,0x28,0x50,0x01,0xFF,0xFF,0xBE,0x41,0x45,0x54,0x06,0x7C,0x00,
0x00,0xF0,0xA2,0xA0,0x00,0x07,0xDF,0xFF,0x00,0x7E,0x62,0xA2,0xAA,0x06,0x7C,0x00,
0x00,0xF1,0x51,0x40,0x00,0x18,0xFF,0xFE,0x00,0x7E,0x21,0x45,0x54,0x06,0x7C,0x00,
0x00,0xF0,0xA2,0x80,0x00,0x21,0x9F,0xFC,0x00,0x1F,0x22,0xA2,0xAA,0x06,0x7C,0x00,
0x00,0xF1,0x50,0x00,0x00,0x46,0x3F,0xFC,0x00,0x07,0x21,0x45,0x54,0x06,0x7C,0x00,
0x00,0xF0,0xA2,0xA0,0x00,0x5C,0x7F,0x78,0x00,0x03,0x20,0x02,0xA8,0x06,0x7C,0x00,
0x00,0xF0,0x05,0x50,0x00,0x38,0xEE,0x78,0x00,0x00,0x60,0x01,0x50,0x06,0x7C,0x00,
0x00,0xF2,0x0A,0xA0,0x00,0x30,0xDC,0x70,0x00,0x00,0x30,0x00,0x00,0x06,0x7C,0x00,
0x00,0xF5,0x15,0x50,0x00,0x61,0x98,0x70,0x00,0x00,0x18,0x00,0x00,0x06,0x7C,0x00,
0x00,0xF2,0xAA,0xA0,0x00,0xC1,0x38,0x60,0x00,0x00,0x0C,0x00,0x00,0x00,0x7C,0x00,
0x00,0xF5,0x15,0x50,0x01,0x82,0x30,0x60,0x00,0x00,0x04,0x00,0x00,0x14,0x7C,0x00,
0x00,0xF0,0x2A,0xA0,0x53,0x02,0x20,0x40,0x00,0x00,0x06,0x00,0x00,0x2A,0x7C,0x00,
0x00,0xF3,0x15,0x40,0xA2,0x00,0x20,0x40,0x00,0x00,0x0E,0x00,0x0A,0x14,0x7C,0x00,
0x00,0xF3,0x2A,0x80,0x56,0x00,0x00,0x40,0x00,0x00,0x1F,0x00,0x15,0x2A,0x7C,0x00,
0x00,0xF3,0x15,0x00,0xA4,0x00,0x00,0x00,0x00,0x00,0x39,0x00,0x0A,0x14,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x15,0x00,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x0A,0x15,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x07,0x80,0x00,0x2A,0xFC,0x00,
0x00,0xF3,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x0E,0x80,0x00,0x55,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x28,0xAA,0xFC,0x00,
0x00,0xF3,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x50,0x55,0x7C,0x00,
0x00,0xF3,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x01,0xC0,0x28,0xAA,0xFC,0x00,
0x00,0xF3,0x00,0x14,0x08,0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x50,0x55,0x7C,0x00,
0x00,0xF3,0x00,0x28,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0xAA,0xFC,0x00,
0x00,0xF3,0x05,0x14,0x07,0xFC,0x0F,0xFF,0xF0,0x80,0x18,0xC0,0x00,0x55,0x7C,0x00,
0x00,0xF3,0x0A,0xA8,0x0C,0x1C,0x08,0x00,0x1F,0x80,0x78,0xC0,0x00,0x2A,0x7C,0x00,
0x00,0xF3,0x15,0x00,0x0C,0x08,0x08,0x00,0x1C,0x80,0x78,0xC0,0x00,0x00,0x7C,0x00,
0x00,0xF3,0x0A,0x80,0x0A,0x10,0x04,0x00,0x0C,0x80,0x72,0xC0,0x00,0x06,0x7C,0x00,
0x00,0xF3,0x15,0x15,0x19,0xC0,0x03,0x00,0x03,0x00,0x3E,0xC0,0x00,0x06,0x7C,0x00,
0x00,0xF3,0x0A,0x2A,0x90,0x3E,0x00,0xFF,0xFC,0x00,0x7C,0x81,0x40,0x06,0x7C,0x00,
0x00,0xF3,0x00,0x55,0x50,0x3D,0x00,0x00,0x00,0x00,0x7C,0x80,0xA0,0x06,0x7C,0x00,
0x00,0xF3,0x28,0xAA,0x90,0x1F,0x00,0x00,0x00,0x00,0x79,0xA9,0x40,0x06,0x7C,0x00,
0x00,0xF3,0x54,0x55,0x53,0x1C,0x1C,0x01,0x50,0x00,0x3D,0x50,0xA0,0x06,0x7C,0x00,
0x00,0xF3,0x28,0xAA,0x9C,0x08,0x03,0x82,0xA8,0x00,0x7F,0x28,0x00,0x06,0x7C,0x00,
0x00,0xF3,0x50,0x55,0x19,0x08,0x00,0x71,0x50,0x00,0x7A,0x50,0x00,0x06,0x7C,0x00,
0x00,0xF3,0x00,0xAA,0x2A,0x08,0x7C,0x0C,0x00,0x00,0x66,0x01,0x50,0x06,0x7C,0x00,
0x00,0xF3,0x00,0x54,0x4D,0x08,0x03,0x02,0x00,0x00,0x0C,0x02,0xA8,0x06,0x7C,0x00,
0x00,0xF3,0xFF,0x28,0x16,0x08,0x38,0xC1,0x00,0x00,0x18,0x85,0x55,0xFE,0x7C,0x00,
0x00,0xF1,0xFF,0x80,0x87,0x08,0x06,0x30,0x00,0x00,0x31,0x4A,0xA9,0xFC,0x7C,0x00,
0x00,0xF0,0x00,0x00,0x29,0xCC,0x01,0x08,0x80,0x00,0xE2,0x85,0x54,0x00,0x7C,0x00,
0x00,0xF0,0x00,0x00,0x00,0x7E,0x00,0x84,0x00,0x03,0x81,0x4A,0xA8,0x00,0x7C,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

uchar column; // 横坐标
uchar line; // 纵坐标
uchar code1; // 代码寄存器

sbit LCD_WR = P3^2; // 写操作信号
sbit LCD_RD = P3^3; // 读操作信号
sbit LCD_CD = P3^4; // 通道挑选信号
sbit LCD_DATA = P1; // 数据端口

//指令&数据读写状况
void CheckRW(void)
{
do
{
LCD_DATA = 0XFF; // LCD_DATA口置”1″
LCD_CD = 0X01; // 指令写入通道
LCD_RD = 0X00; // RD=0
ACC = LCD_DATA; // 读操作
LCD_RD = 0X01; // RD=1
}

while ((ACC&0x03) != 0X03); // 低电平忙
}
//数据主动写状况
void AutoWrite(void)
{
do
{
LCD_DATA = 0XFF; // LCD_DATA口置”1″
LCD_CD= 0X01; // 指令写入通道
LCD_RD = 0X00; // RD=0
ACC = LCD_DATA; // 读操作
LCD_RD = 0X01; // RD=1
}
while((ACC&0X08)!= 0x08); // 低电平忙
}
//数据写入函数
void WriteData(uchar uData)
{
CheckRW(); // 指令&数据读写状况
ACC = uData; // 暂存累加器
LCD_CD = 0X00; // 数据写入通道
LCD_DATA = ACC; // 读取数据
LCD_WR = 0X00; // WR=0
LCD_WR = 0X01; // WR=1
}
//无参指令写入函数
void WriteCom(uchar Command)
{
CheckRW(); // 检测指令读写状况
LCD_DATA = Command; // 指令写入
LCD_WR = 0X00; // WR=0
LCD_WR = 0X01; // WR=1
}
//单参数指令写入函数
void WriteCom1(uchar Par,uchar Com)
{
CheckRW(); // 检测指令读写
WriteData(Par); // 数据写入
CheckRW(); // 检测指令读写
WriteCom(Com); // 指令写入
}
//双参数指令写入函数
void WriteCom2(uchar Par1,uchar Par2,uchar Comd)
{
CheckRW(); // 检测指令读写
WriteData(Par1); // 数据写入
CheckRW(); // 检测指令读写
WriteData(Par2); // 数据写入
CheckRW(); // 检测指令读写
WriteCom(Comd); // 指令写入
}

//LCM初始化函数
void LcmInit( void )
{
WriteCom2(0x00,0x00,0x40); // 设置文本显现区首地址
WriteCom2(0x10,0x00,0x41); // 设置文本显现区宽度
WriteCom2(0x00,0x08,0x42); // 设置图形显现区首地址0x0800
WriteCom2(0x10,0x00,0x43); // 设置图形显现区宽度
WriteCom(0xA7); // 设置光标形状 8×8方块
WriteCom(0x80); // 显现方法设置 文本xor图形
WriteCom(0x98); // 显现开关设置 文本开,图形开,光标闪耀关
}
//清显现存储器函数
void LcmClear( uchar FillByte )
{
uint i = 8192; // 此处仅清8K RAM,假如32K RAM都运用,请修正i=32768

WriteCom2(0x00,0x08,0x24);
WriteCom(0xB0); // 进入主动写

while(i–)
{
AutoWrite(); // 数据主动写状况
WriteData( FillByte ); // 写入数据
}

WriteCom(0xB2); // 退出主动写
}
//设定显现地址函数
void LocateXY(uchar x,uchar y,uchar mode)
{
if (mode) // mode=1为图形方法
{
y += 0x08; // 假如图形形式要加上图形区首地址0x0800
column = x;
line = y;
}
else
{
; // 不然什么都不做
}
}
//图形写入函数
void WriteTX( void )
{
uint i = 0;

LocateXY(0x00,0x00,1); // 核算图形显现区首地址为0800H
WriteCom2(column,line,0x24); // 设置显现RAM地址

while (i < 1024)
{
WriteCom1(CCTAB[i++],0xC0);
}
}
//主程序
void main( )
{
P3 = 0X1C; // 直接操控方法操控线初始化
LcmInit (); // 初始化
LcmClear (0X00); // 清屏
WriteTX(); // 图形演示

while(1)
{
;
}
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ceping/275923.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部