|
|
View previous topic :: View next topic |
Author |
Message |
MAKInnovation
Joined: 16 Nov 2010 Posts: 61
|
HT1621 holtek lcd driver |
Posted: Tue Mar 05, 2013 4:40 am |
|
|
Dear All;
I am working on ht1621 equivalent lcd driver and wrote a following code with the help of previous sample codes.
I got nothing correct on lcd display.
writeall_1621(2,2,2); is working but the values are totally incorrect.
Can anyone help me to correct the following code or suggest me if
anything is wrong with the setup ?
Code: | #include <16F870.h>
#fuses HS,NOWDT,LVP,protect, NOBROWNOUT
#use delay(clock=20000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
//HT1621 connections
#define cs PIN_A0
#define wr PIN_A1
#define dat PIN_A2
#define bias 0x52
#define system 0x02
#define system_dis 0x00
#define lcdon 0x06
#define lcdoff 0x04
#define toneon 0x12
#define toneoff 0x10
#define test 0xc0
#define normal 0xc6
#define wdt1 0x0e
void sendbit_1621(unsigned char data,unsigned char cnt)
{
unsigned char i;
for (i=0;i<cnt;i++)
{
if ((data&0x80)==0) output_low(dAt);
else output_high(dAt);
output_low(wr);
delay_cycles(25);
//delay_ms(1);
output_high(wr);
//delay_cycles(25);
data<<=1;
}
}
void SendDataBit_1621(unsigned char data,unsigned char cnt)
{
unsigned char i;
for(i =0; i <cnt; i ++)
{
if((data&0x01)==0) output_low(dat);
else output_high(dat);
output_low(wr);
delay_cycles(25);
output_high(wr);
//delay_cycles(25);
data>>=1;
}
}
void lcd1621_init(void)
{
output_low(cs);
output_high(wr);
delay_cycles(25);
//delay_ms(10);
output_low(wr);
delay_cycles(25);
//delay_ms(10);
}
void sendcmd(unsigned char command)
{
lcd1621_init();
sendbit_1621(0x04,3);
sendbit_1621(command,8);
output_high(wr);
output_high(cs);
output_high(dat);
}
void write_1621(unsigned char addr,unsigned char data)
{
output_low(cs);
sendbit_1621(0xa0,3);
sendbit_1621(addr,6);
senddatabit_1621(data,4);
output_high(cs);
}
void writeall_1621(unsigned char addr,unsigned char *p,unsigned char cnt )
{
unsigned char i;
output_low(cs);
sendbit_1621(0xa0,3);
sendbit_1621(addr,6);
for (i=1;i<cnt;i++,p++)
{
senddatabit_1621(*p,4);
}
output_high(cs);
}
void write_74164(char eo)
{
unsigned int i;
for(i=1;i<=8;i++) { // Clock out bits from the eo array
if((((eo))& 0x80)==0)
output_low(DAT);
else
output_high(DAT);
shift_left(&eo,1,0);
output_low(WR);
delay_cycles(25);
output_high(WR);
}
}
void main()
{
unsigned char i,j;
setup_adc( ADC_OFF );
setup_adc_ports(NO_ANALOGS );
sendcmd(wdt1);
sendcmd(bias);
sendcmd(system_dis);
sendcmd(system);
sendcmd(lcdoff);
sendcmd(lcdon);
//write_1621(0X01,0X01); //get seg1 com3 area
//write_1621(0X09,0X03); //get seg1 com3 area
writeall_1621(2,2,2);
output_toggle(Pin_c0);
output_toggle(Pin_c1);
output_toggle(Pin_c2);
output_toggle(Pin_c3);
output_toggle(Pin_c4);
output_toggle(Pin_c5);
output_toggle(Pin_c6);
output_toggle(Pin_c7);
while(1);
}
|
Ashraf |
|
|
MAKInnovation
Joined: 16 Nov 2010 Posts: 61
|
|
Posted: Tue Mar 05, 2013 10:51 pm |
|
|
Still waiting........... |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Mar 06, 2013 2:59 am |
|
|
I'm not surprised you've had no response.
I have difficulty understanding your question.
I find your code a pain to follow as you're very inconsistent with indentation.
I don't see why you have not started with either the CCS or the flex drivers.
Why not reduce your code to the minimum which illustrates the problem?
Mike |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Wed Mar 06, 2013 8:32 am |
|
|
I took some time to download and scan the manual...
This LCD chip is NOT a common LCD! Uses it's own 3 wire serial communications so CCS and FLEX drivers won't work.
While the OP says it 'kinda works', I suspect a timing issue or faulty sequence of commands.
Since it isn't a 'normal' or 'common' LCD chip, support here will be very minimal however there is a lot available from the Web, though it'll take time to search.
As it does not contain any character maps, it's up to the programmer to do so.
hth
jay |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Mar 06, 2013 9:06 am |
|
|
I admit I hadn't looked up the data sheet for the LCD and not realised CCS and FLEX wouldn't work.
Sorry about that.
Thank you jay.
Now, I'm even less surprised there was no help forthcoming.
Mike
EDIT If this LCD is anything like the usual ones, a one second delay at the start often helps. |
|
|
MAKInnovation
Joined: 16 Nov 2010 Posts: 61
|
|
Posted: Thu Mar 07, 2013 12:46 am |
|
|
Thanks for your kind response
Yes, this lcd is not common and very less material available on internet for the same.
The code i posted is also copied from an internet source and then i made some changes to tune it up for my pic controller in CCS.
Well I have few questions to ask:
1. I use 20MHz crystal : is it right or i will change it to 4Mhz.
2. I use port A, would i change it to other port ?
3. Would this pic microcontroller work on 3V ?
Because, I upload hex file to my controller on 5V and then i disconnect 5V, connect lcd and then connect 3V with the circuit. and observe the program execution.
4. On 3V: my PicKit 2 does not program the pic easily. It does but in multiple tries.
5. Is it possible for anyone to share a running code?
Regards
Ashraf |
|
|
MAKInnovation
Joined: 16 Nov 2010 Posts: 61
|
|
Posted: Thu Mar 07, 2013 12:50 am |
|
|
One more think i forgot to write in my previous reply.
-The lcd operating voltage rate is from 2.8 to 3.5V.
and my lcd support HT1621 or equivalent driver code.
Ashraf |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|