#include "Library.h"
void SenCmd_1621(unsigned char command);
void Write_1621(unsigned char Data,unsigned char Count);
void Write_data(uchar addr,uchar sdata);
//定义HT1621的命令
#define ComMode 0x50 //4COM,1/3bias 1000 010 1001 0
#define RCosc 0x30 //内部RC振荡器(上电默认)1000 0011 0000
#define LCD_On 0x06 //打开LCD 偏压发生器1000 0000 0 11 0
#define Sys_En 0x02 //系统振荡器开 1000 0000 0010
#define LCD_Off 0x04
void Drive_Lcd(void)
{
unsigned char x;
SenCmd_1621(Sys_En); //系统振荡器开
SenCmd_1621(ComMode); //4COM,1/3bias
SenCmd_1621(RCosc); //内部RC振荡器
SenCmd_1621(LCD_On); //打开LCD 偏压发生器
Write_data(0x00,0xFF); //写地址和数据
}
//-----------------------//
void SenCmd_1621(unsigned char command)
{
CLR_CS;
Write_1621(0x80,4);
Write_1621(command,8);
SET_CS;
NOP;
NOP;
}
//-----------------------//
void Write_1621(unsigned char Data,unsigned char Count)
{
unsigned char x;
for (x = 0; x<Count; x++)
{
CLR_DATA;
CLR_WR;
if (Data & 0x80)
{
SET_DATA;
}
NOP;
NOP;
SET_WR;
Data <<= 1;
}
}
//-----------------------//
void Write_data(uchar addr,uchar sdata)
{
addr<<=2;
CLR_CS;
Write_1621(0xA0,3); //写入标志码“101”
Write_1621(addr,6); //写入addr 的高6位
Write_1621(sdata,8); //写入data 的8位
SET_CS;
} |