|
发表于 2005-11-23 13:59:54
|
显示全部楼层
(转)
--调试ok的液晶驱动芯片HT1621的c程序
#include
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
//定義HT1261 LCD驅動片命令參數
#define BIAS 0X52
#define RC256 0X30
#define SYSTEN 0X02
#define SYSDIS 0X00
#define LCDON 0X06
//定義HT1261 LCD驅動片的引腳
sbit lc=PSW^0;
sbit lcd_data=P1^0;
sbit lcd_cs=P1^1;
sbit lcd_wr=P1^3;
void lcdint(void)//初始化HT1621.
{
lcd_cs=0;
lcd_wr=1;
_nop_();
lcd_wr=0;
_nop_();
}
void sendb0(uchar id,uchar n)
{
uchar i;
for(i=0;i {
if(id>=0x80)
lcd_data=1;
else
lcd_data=0;
lcd_wr=1;
_nop_();
_nop_();
lcd_wr=0;
_nop_();
_nop_();
id<<=1;
}
}
void sendcom(uchar command)
{
uchar a=0x80,i=4,d=8;
lcdint();
sendb0(a,i);
sendb0(command,d);
lcd_wr=1;
lcd_cs=1;
lcd_data=1;
}
void INT1621(void) //送命令字
{
uchar command;
command=BIAS; // 1/3 bais . 4 duty
sendcom(command);
command=RC256; //啟動內部256KRC 振蕩器
sendcom(command);
command=SYSTEN;
sendcom(command);
command=LCDON; //開啟LCD
sendcom(command);
}
//以上程序使能LCD驅動.
void send1621data()
{
uchar a=0x01,b=0x80,c=0x40,d=0x08;
uchar j,k;
lcdint();
sendb0(b,a);
sendb0(c,d);//從display buffer RAM 0x0000 開始
for(j=0;j<16;j++) //將X1[]數組需要顯示的數据逐個送RAM.
{
k=X1[j];
sendb0(k,d);
}
}
//以上是//往HT1621 display buffer RAM送要顯示數据
main()
{
for(;;)
{
INT1621();
send1621data();
...............
...............
}
} |
|