stinger-dk
Newbie level 1
ht1621
I am using AT89C51 to run a 24 seg, 4 com lcd using HT1621 driver. I am using C with Keil uVision.
Using the code below, all i get is 8 on segments. no matter what i write, those 8 segments will go on. rest of the segments will stay off... The segments which are on correspong to addresses 3, 4, 5 and 6 of HT1621.
Please also explain why are there 6 address lines when there are only 32 locations to be addressed?
I have used 11.059Mhz crystal for 89C51 so delays in nano seconds (for th1 and tsu1) are not possible. But i don't think they should be a problem. I have used 32.768KHz external crystral for HT1621.
All help will be greatly appreciated Thanks in advance!!
Here is the code:
I am using AT89C51 to run a 24 seg, 4 com lcd using HT1621 driver. I am using C with Keil uVision.
Using the code below, all i get is 8 on segments. no matter what i write, those 8 segments will go on. rest of the segments will stay off... The segments which are on correspong to addresses 3, 4, 5 and 6 of HT1621.
Please also explain why are there 6 address lines when there are only 32 locations to be addressed?
I have used 11.059Mhz crystal for 89C51 so delays in nano seconds (for th1 and tsu1) are not possible. But i don't think they should be a problem. I have used 32.768KHz external crystral for HT1621.
All help will be greatly appreciated Thanks in advance!!
Here is the code:
Code:
#include <reg51.h>
//Interface with HT1621
sbit wr=P1^0;
sbit dt=P1^1;
sbit cs=P1^2;
sbit rd=P1^3;
int com_reg; //Bits to be transferred is stored in com_reg
bit com_mode=0; //Tells that commands are being transferred and not data
unsigned int mask=0x8000;
bit haha=0;
void delay (unsigned int j)
{
unsigned int i=0;
for(;i<j;i++);
}
void cs_pulse(void)
{
cs=1;
delay(1); //For t(CS)
cs=0;
}
void lcd_wr(void)
{
//This will write data to HT1621
rd=1; //HT1621 clocks data out at falling edge of rd clock
wr=1; //Initializing rd and wr. rd will remain 1 forever.
cs_pulse();
delay(1); //For t(su1)
mask=0x8000;
if(com_mode==0)
{
while(mask!=0x0004)
{
wr=0;
delay(1); //For t(CLK)
haha=com_reg & mask;
dt=haha;
delay(1);
wr=1;
delay(2);
mask>>=1;
}
}
else if(com_mode==1)
{
while(mask!=0x0008)
{
wr=0;
delay(1); //For t(CLK)
haha=com_reg & mask;
dt=haha;
delay(1);
wr=1;
delay(2);
mask>>=1;
}
}
delay(1); //For t(h1)
cs=1;
}
void main()
{
//Initialization
dt=0;
delay(10000);
com_mode=1;
com_reg=0x8020; //SYS EN
lcd_wr();
com_reg=0x8560; //BIAS 1/3 with 4 commons
lcd_wr();
com_reg=0x8090; //TIMER DIS
lcd_wr();
com_reg=0x80A0; //WDT DIS
lcd_wr();
com_reg=0x8280; //XTAL 32K
lcd_wr();
com_reg=0x8060; //LCD ON
lcd_wr();
com_mode=0;
//Following code will put switch segments corresponding to addresses 1 and 2 of ht1621 on.
com_reg=0xA0F8;
lcd_wr();
com_reg=0xA178;
lcd_wr();
}