码迷,mamicode.com
首页 > 其他好文 > 详细

HT1621B液晶驱动(附电路图)

时间:2015-01-16 16:46:08      阅读:599      评论:0      收藏:0      [点我收藏+]

标签:单片机   lcd   ht1621b   

最近做了一个项目用到了HT1621,电路图+datasheet+code


HT1621B datasheet

技术分享

#include "ht1621.h"


void ht1621_send_high_order_data(UCHAR data, UCHAR len)
{
	UCHAR i;

	for (i=0; i<len; i++)
	{
		if((data&0x80) == 0)
		{
			Set_Port_Val(HT_DATA, 0);	
		}
		else
		{
			Set_Port_Val(HT_DATA, 1);
		}
		
		Set_Port_Val(HT_WR, 0);
		Delay(4);
		Set_Port_Val(HT_WR, 1);	
		
		data <<= 1;
	}
}

void ht1621_send_low_order_data(UCHAR data, UCHAR len)
{
	UCHAR i;
	
	for (i=0; i<len; i++)
	{
		if((data&0x01) == 0)
		{
			Set_Port_Val(HT_DATA, 0);	
		}
		else
		{
			Set_Port_Val(HT_DATA, 1);
		}
		
		Set_Port_Val(HT_WR, 0);
		Delay(4);
		Set_Port_Val(HT_WR, 1);	
		
		data >>= 1;
	}
}

void ht1621_send_cmd(UCHAR command)
{
	Set_Port_Val(HT_CS, 0);	
	ht1621_send_high_order_data(0x80, 4);
	ht1621_send_high_order_data(command, 8);
	Set_Port_Val(HT_CS, 1);	
}

void ht1621_write(UCHAR addr, UCHAR data)
{
	Set_Port_Val(HT_CS, 0);
	ht1621_send_high_order_data(0xA0, 3);
	ht1621_send_high_order_data(addr<<2, 6);
	ht1621_send_low_order_data(data, 8);
	Set_Port_Val(HT_CS, 1);
}

void ht1621_write_all(UCHAR addr, UCHAR *p, UCHAR len)
{
	UCHAR i;
	
	Set_Port_Val(HT_CS, 0);
	ht1621_send_high_order_data(0xA0, 3);
	ht1621_send_high_order_data(addr<<2, 6);
	
	for (i=0; i<len; i++, p++)
	{
		ht1621_send_low_order_data(*p, 8);
	}
	
	Set_Port_Val(HT_CS, 1);	
}



void ht1621_clr_all_display()
{
	UCHAR i;
	UCHAR addr = 0;
	
	for (i=0; i<16; i++)
	{
		ht1621_write(addr, 0x00);
		addr += 2;
	}
}

void ht1621_all_display()
{
	UCHAR i;
	UCHAR addr = 0;
	
	for (i=0; i<16; i++)
	{
		ht1621_write(addr, 0xFF);
		addr += 2;
	}	
}

void ht1621_init()
{
	ht1621_send_cmd(HT_SYS_EN);
	ht1621_send_cmd(HT_RCOSC);
	ht1621_send_cmd(HT_BISA_COM);
	ht1621_send_cmd(HT_LCD_ON);
}


void set_lcd_on()
{
	ht1621_send_cmd(HT_LCD_ON);
}

void set_lcd_off()
{
	ht1621_send_cmd(HT_LCD_OFF);
}

#ifndef _HT1621_H
#define _HT1621_H


#define HT_BISA_COM			0x52		//(1<<1) | (0<<3) | (1<<4) | (0<<5) | (1<<6) | (0<<7) | (0<<8) | (0<<9) | (0<<10) | (1<<11)
#define HT_LCD_OFF			0x04		//(0<<1) | (1<<2) | (0<<4) | (0<<5) | (0<<6) | (0<<7) | (0<<8) | (0<<9) | (0<<10) | (1<<11)
#define HT_LCD_ON			0x06		//(1<<1) | (1<<2) | (0<<4) | (0<<5) | (0<<6) | (0<<7) | (0<<8) | (0<<9) | (0<<10) | (1<<11)
#define HT_WRITE_CMD		0x80		//(0<<0) | (0<<1) | (1<<2)  | (0<<3) | (1<<4) | (0<<5) | (1<<6) | (0<<7) | (1<<8)
#define HT_WRITE_DATA		0xA0
#define HT_SYS_EN			0x02
#define HT_RCOSC			0x30


#endif




HT1621B液晶驱动(附电路图)

标签:单片机   lcd   ht1621b   

原文地址:http://blog.csdn.net/w89436838/article/details/42778201

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!