LCD驱动芯片HT16c21使用注意事项

1.在使用LCD驱动芯片HT16c21芯片时应该注意,在写其显示存储器之前一定要对驱动参数进行配置,
如:

void HT16C21_Init(void)
{
WriteCommdByte(0x82,0x00);   //选择1/4duty和1/3bias

WriteCommdByte(0x84,0x03);   //开LCD显示屏和内部系统振荡器

WriteCommdByte(0x86,0x01);   //选择帧频率为160Hz

WriteCommdByte(0x88,0x00);   //关闭显示模式的闪烁

WriteCommdByte(0x8a,0x10);     //共用引脚选择VLCD调整VLCD输出电压为1.000*VDD
   

}

/*********************************************************************************************************
** Function name     : WriteCommdByte
** Descriptions      : 设置HT16C21参数
** input parameters  : ComByte(命令);ComSet(写入的设置数据)
** output parameters : 无
** Returned value    : 无
*********************************************************************************************************/
_Bool  WriteCommdByte(unsigned char ComByte, unsigned char ComSet) 
{
unsigned char ack;
IIC_Start();       //开始数据传递
ack=IIC_WriteByte(0x70); //HT16C21芯片地址,硬件I2c时为0x38
   if(ack==0) {return 0;}
ack=IIC_WriteByte(ComByte); //写入命令
   if(ack==0) {return 0;}
ack=IIC_WriteByte(ComSet);  //写入命令设置数据
   if(ack==0) {return 0;}
IIC_Stop();        //停止数据传递
return 1;

}

2.读和写显示存储器的命令都为0x80

/*********************************************************************************************************
** Function name : WriteRAMByte
** Descriptions : 向HT16C21中的指定地址写入数据
** 在指定地址addr处写入数据date
** input parameters : Address (储存指定的地址)Data 存储读出的数据
** output parameters : 无
** Returned value : 无
*********************************************************************************************************/
void WriteRAMByte( unsigned char Address, unsigned char Data)
{
     IIC_Start(); //开始数据传递
     IIC_WriteByte(0x70); ////HT16C21芯片地址,硬件I2c时为0x38
     IIC_WriteByte(0x80); //写入读写命令
     IIC_WriteByte(Address); //写入指定地址
IIC_WriteByte(Data); //向当前地址(上面指定的地址)写入数据
     IIC_Stop(); //停止数据传递
}
/*********************************************************************************************************/

/*********************************************************************************************************
** Function name : IIC_ReadSet
** Descriptions : 从HT16C21中的指定地址读取数据
** 在指定地址读取数据
** input parameters : Address 指定地址
** output parameters : 无
** Returned value : ReadValue 存储的数据
*********************************************************************************************************/
unsigned char IIC_ReadSet( unsigned char Address)
{   
     unsigned char ReadValue,Ack;
     IIC_Start(); //开始数据传递
    Ack= IIC_WriteByte(0x70); ////HT16C21芯片地址,硬件I2c时为0x38
     if(Ack== 0) { return 0;}
    Ack= IIC_WriteByte(0x80); //选择要操作的HT16C21芯片,写入读数据命令
     if(Ack== 0) { return 0;}
    Ack= IIC_WriteByte(Address); //写入读数据的指定地址
if(Ack== 0) { return 0;}
     IIC_Start(); //开始数据传递
    Ack= IIC_WriteByte(OpRead); //选择要操作的HT16C21芯片,写入读操作指令
if(Ack== 0) { return 0;}
    ReadValue= IIC_ReadByte();    //在指定地址读取数据
     IIC_Stop();      //停止数据传递

     return(ReadValue); //将指定地址读出的数据返回
}
/*********************************************************************************************************/

猜你喜欢

转载自blog.csdn.net/m0_38096844/article/details/80929244