#define
LCD_ON
0x03
//打开偏压发生器
#define LCD_OFF 0x02 //关闭偏压发生器
//#define BIAS 0x20 //1/2偏压,2com口
//#define BIAS 0x24 //1/2偏压,3com口
#define BIAS 0x28 //1/2偏压,4com口
//#define BIAS 0x21 //1/3偏压,2com口
//#define BIAS 0x25 //1/3偏压,3com口
//#define BIAS 0x29 //1/3偏压,4com口
#define SYSEN 0x01 //打开振荡器
#define RC256K 0x18 //内部256RC
#define EXT256K 0x1c
uchar disprom[32];
uchar COM[4] = {0x01,0x02,0x04,0x08};
void SendBit_1621(uchar sdata,uchar cnt) //data 的高cnt 位写入HT1621,高位在前
{
uchar i;
for(i=0; i
{
if((sdata&0x80)==0)
{
DATA = 0;
}
else
{
DATA = 1;
}
WR = 0;
asm("nop");
asm("nop");
WR = 1;
sdata <= 1;
}
}
void SenddataBit_1621(uchar sdata,uchar cnt) //data的低cnt位写入1621
{
uchar i;
for(i=0; i
{
if((sdata&0x01)==0)
{
DATA = 0;
}
else
{
DATA = 1;
}
WR = 0;
asm("nop");
asm("nop");
WR = 1;
sdata >>= 1;
}
}
void Sendcmd(uchar command)
{
CS = 0;
SendBit_1621(0x80,3); //写入标志码"100"
SendBit_1621(command,9); //写入 9 位数据,其中前 8 位为 command 命令,最后 1 位任意
CS = 1;
}
void Write_1621(uchar addr,uchar dat)
{
CS = 0;
SendBit_1621(0xa0,3); //写入标志码"101"
SendBit_1621(addr<2,6); //写入 6 位 addr
SenddataBit_1621(dat,4); //写入 data 的低 4 位
CS = 1;
}
void WriteAll_1621(uchar addr,uchar *p,uchar cnt)
{
uchar i;
CS = 0;
SendBit_1621(0xa0,3); //写入标志码"101"
SendBit_1621(addr<2,6); //写入 6 位 addr
for(i =0; i
{
SenddataBit_1621(*p,8);
}
CS = 1;
}
//使用说明:dispON(COM,PIN);
//dispON(1,24); 使能COM1,PIN24脚的液晶显示
void dispON(uchar com,uchar line)
{
uchar tmp = 0;
disprom[line-1] = disprom[line-1]|COM[com-1];
tmp = disprom[line-1];
Write_1621(line-1,tmp);
asm("nop");
}
//使用说明:dispOFF(COM,PIN);
//dispON(1,24); 关闭COM1,PIN24脚的液晶显示
void dispOFF(uchar com,uchar line)
{
uchar tmp = 0;
disprom[line-1] = disprom[line-1]&~(COM[com-1]);
tmp = disprom[line-1];
Write_1621(line-1,tmp);
asm("nop");
}
void HT1621_Init(void)
{
uchar sec = 0;
uchar j = 0;
for(j=0; j<32; j++)
{
disprom[j] = 0;
}
Sendcmd(BIAS); //设置偏压和占空比
Sendcmd(RC256K); //RC256
Sendcmd(SYSEN); //打开系统振荡器
Sendcmd(LCD_ON); //打开 LCD偏压发生器
//cleandisp(); //清除显示ROM内容
// Sendcmd(LCD_OFF); //关闭 LCD显示
}