Searching \ for 'Hitachi LCD module' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/lcds.htm?key=lcd
Search entire site for: 'Hitachi LCD module'.

Truncated match.
PICList Thread
'Hitachi LCD module'
1996\07\23@053324 by Andy Errington

flavicon
face
Hi All,

I am trying to get an Hitachi LM016L LCD module working with a PIC 84,
with no success.  I have had the module working with a STAMP, and I
understand everything I need to do to setup and use the module, but it
just ain't workin'.

I am using PORTA <0:3> for the LCD data port (connected to the MSB of
the LCD data pins), and PORTB <4:6> for E, RS and R/^W.  Obviously I am
attempting to initialise the module for 4 bit operation.  My question
is:  am I likely to have problems with PORT A, and should I stick
everything on PORT B?

This is a simple problem, I just need reassurance to keep trying.

Andy (the other one)
Lancaster, UK

1996\07\23@055612 by Kalle Pihlajasaari

flavicon
face
Hi Andy (too),

> I am trying to get an Hitachi LM016L LCD module working with a PIC 84,
> with no success.  I have had the module working with a STAMP, and I
> understand everything I need to do to setup and use the module, but it
> just ain't workin'.
>
> I am using PORTA <0:3> for the LCD data port (connected to the MSB of
> the LCD data pins), and PORTB <4:6> for E, RS and R/^W.  Obviously I am
> attempting to initialise the module for 4 bit operation.  My question
> is:  am I likely to have problems with PORT A, and should I stick
> everything on PORT B?

Not having used that direct configuration with the LCD I am speaking
from general experience with the LCD and C84 devices.

If it worked with the Stamp then your problem is probably timing related.

Put pauses of 2 ms after mode, clear and home commands and 100 us after
ather commands.  Also send the enable pulse to the display with
3 instructions (lo-hi-lo) with possibly a short delay after the
data and address times have settled, the PIC is FAST and the LCD is
SLOW.

> This is a simple problem, I just need reassurance to keep trying.

If nothing helps, start the wiring and code from scratch and you will
probably notice your mistake :-)

Cheers
--
Kalle Pihlajasaari     spam_OUTkalleTakeThisOuTspamdata.co.za
Interface Products     Box 15775, Doornfontein, 2028, South Africa
+27 (11) 402-7750      Fax: +27 (11) 402-7751

1996\07\23@063628 by Odriozola Belden

flavicon
face
Really like what you write after your name (the other one).

Rogerio


At 10:33 AM 23/07/96 +0100, you wrote:
{Quote hidden}

1996\07\23@085346 by Norm Cramer

flavicon
face
I wonder if your problem is port A.  Pin RA4 is an open collector output and may
float if the LCD module doesn't pull it up.  This could cause problems when
doing the initialization.  I usually use port A as the control lines and
port B as the data.  If you are using the Microchip app notes, there are a
few errors.  I have an example to control the LCD from a 16C84 but I can't
find the web address at the moment.  E-mail me if you are interested in the
code.

Norm


At 10:33 AM 7/23/96 +0100, you wrote:
{Quote hidden}

1996\07\23@124337 by Walter Banks

picon face
Andy,

> I am trying to get an Hitachi LM016L LCD module working with a PIC 84,
> with no success.  I have had the module working with a STAMP, and I
> understand everything I need to do to setup and use the module, but it
> just ain't workin'.
>
> I am using PORTA <0:3> for the LCD data port (connected to the MSB of
> the LCD data pins), and PORTB <4:6> for E, RS and R/^W.  Obviously I am
> attempting to initialise the module for 4 bit operation.  My question
> is:  am I likely to have problems with PORT A, and should I stick
> everything on PORT B?

I suspect that several others are right about timing. The following code
is from a standarized Embedded C library that I have been using for a
few years. I copied the following listing fragment from a project I did
for Circuit Cellar. It was compiled with MPC on a 16C74. The LCD display
was connected to Port D in this case. To save an I/O pin I generally
connect the R/^W to ground.



Walter Banks Byte Craft

                 #include <lcd4.c>
                 /********************************************************
                  *  Device driver for 4 bit LCD interface using         *
                  *  Hitachi H2570 controllers. These displays are in    *
                  *  configurations from one line by 16 characters to    *
                  *  4 lines by 40 characters                            *
                  *                                                      *
                  *  No warranty is implied or given as to               *
                  *  their usability for any purpose.                    *
                  *                                                      *
                  *       (c) Copyright 1990                             *
                  *       Byte Craft Limited                             *
                  *       Waterloo, Ontario                              *
                  *       Canada N2J 4E4                                 *
                  *       (519) 888-6911                                 *
                  *                                                      *
                  *       Walter Banks                                   *
                  ********************************************************/


0000                              registerx index;
                                 #pragma option p ;
               /*
               ---------------
                              |
                              |
                              |
                         Pn0  |--------------------------\
                         Pn1  |--------------------------+\
                         Pn2  |--------------------------++\
                         Pn3  |--------------------------+++\
                 E Clock Pn4  |-------------------\      ||||
                Register Pn5  |-------------------+-\    ||||
                Select   Pn6  |-                  | |    ||||
                         Pn7  |-                  | |    ||||
                              |                   | |    ||||
                              |                   | |    ||||
                              |                   | |    ||||
                              |           Vcc     | |    ||||
               ---------------             |      | |    ||||
                                           |----  | |    ||||
                                           |    | | |    ||||
                                           -    | | |    ||||
                                      20K | <---+ | |    ||||
                                      pot  |    ||| |    ||||
                                      ----------+++ |    ||||
                                     |       1 |||||||||||||| 14
                                     |        ----------------------------
                                    ---      | ..............             |
                                     -       |  Liquid Crystal Display    |
                                             |                            |
                                              ----------------------------
               */


0005                    #define LCDdata PORTD     /*  Data output         */
0006                    #define LCD_RS PORTD.5    /*  Register select bit */
0007                    #define LCD_E  PORTD.4    /*  Clock bit           */

                   /********************************************************
                    * wLCDdat - Write data word to LCD peripheral          *
                    *  Enter with data word in accumulator                 *
                    *  Delay w120fS after data write                       *
                    ********************************************************/

                               void wLCDdat(unsigned int tempa)
0035                             {
001B 1283    BCF    STATUS,RP0
001C 00B5    MOVWF  35                      /* Write HI nybble word to LCD */
001D 00A1    MOVWF  21             LCDdata = tempa >> 4;
001E 0EA1    SWAPF  21
001F 300F    MOVLW  0Fh
0020 0521    ANDWF  21,W
0021 0088    MOVWF  PORTD
0022 1688    BSF    PORTD,5        LCD_RS  = 1 ;           /* RS->1 */
0023 1608    BSF    PORTD,4        LCD_E   = 1 ;           /* E->1  */
0024 1208    BCF    PORTD,4        LCD_E   = 0 ;           /* E->0  */
0025 1288    BCF    PORTD,5        LCD_RS  = 0 ;           /* RS->0 */
0026 300F    MOVLW  0Fh            LCDdata = tempa & 0x0f;
0027 0535    ANDWF  35,W                     /* Write LO nybble word to LCD */
0028 0088    MOVWF  PORTD
0029 1688    BSF    PORTD,5        LCD_RS  = 1 ;           /* RS->1 */
002A 1608    BSF    PORTD,4        LCD_E   = 1 ;           /* E->1  */
002B 1208    BCF    PORTD,4        LCD_E   = 0 ;           /* E->0  */
002C 1288    BCF    PORTD,5        LCD_RS  = 0 ;           /* RS->0 */

002D 3014    MOVLW  14h            index = 20;
002E 0084    MOVWF  FSR
002F 0384    DECF   FSR            while (--index);        /* 120usec $$$$*/
0030 0804    MOVF   FSR,W
0031 1903    BTFSC  STATUS,Z
0032 2834    GOTO   0034h
0033 282F    GOTO   002Fh
0034 0008    RETURN              }

                    /*********************************************************
                     * wLCDctrl4 - Write control word to LCD peripheral      *
                     *      configured as a 4 bit interface                  *
                     *  Enter with control word in accumulator               *
                     *  Delay w4.5mS if A=0x01 or 0x02 else delay w120fS     *
                     *********************************************************/
                             void wLCDctrl4(unsigned int tempa)
0036                            {
0035 1283    BCF    STATUS,RP0
0036 00B6    MOVWF  36
                                        /* Write HI nybble to LCD */
0037 00A1    MOVWF  21           LCDdata = tempa >> 4;
0038 0EA1    SWAPF  21
0039 300F    MOVLW  0Fh
003A 0521    ANDWF  21,W
003B 0088    MOVWF  PORTD
003C 1608    BSF    PORTD,4      LCD_E   = 1 ;           /* E->1  */
003D 1208    BCF    PORTD,4      LCD_E   = 0 ;           /* E->0  */
003E 300F    MOVLW  0Fh          LCDdata = tempa & 0x0f; /* Write LO nybble to
LCD */
003F 0536    ANDWF  36,W
0040 0088    MOVWF  PORTD
0041 1608    BSF    PORTD,4      LCD_E   = 1 ;           /* E->1  */
0042 1208    BCF    PORTD,4      LCD_E   = 0 ;           /* E->0  */
0043 3014    MOVLW  14h          index = 20;
0044 0084    MOVWF  FSR
0045 0384    DECF   FSR          while (--index);        /* 120usec   */
0046 0804    MOVF   FSR,W
0047 1903    BTFSC  STATUS,Z
0048 284A    GOTO   004Ah
0049 2845    GOTO   0045h
004A 3002    MOVLW  02h          if (tempa <= 2)
004B 1283    BCF    STATUS,RP0
004C 0236    SUBWF  36,W
004D 1903    BTFSC  STATUS,Z
004E 2851    GOTO   0051h
004F 1803    BTFSC  STATUS,C
0050 2860    GOTO   0060h
0051                               {
0051 0384    DECF   FSR             while (--index);
0052 0804    MOVF   FSR,W                      /* 4.6 ms or so delay */
0053 1903    BTFSC  STATUS,Z
0054 2856    GOTO   0056h
0055 2851    GOTO   0051h
0056 0384    DECF   FSR             while (--index);
0057 0804    MOVF   FSR,W
0058 1903    BTFSC  STATUS,Z
0059 285B    GOTO   005Bh
005A 2856    GOTO   0056h
005B 0384    DECF   FSR             while (--index);
005C 0804    MOVF   FSR,W
005D 1903    BTFSC  STATUS,Z
005E 2860    GOTO   0060h
005F 285B    GOTO   005Bh
                                   }
0060 0008    RETURN              }

                             void initLCD(void)
                               {
                                /* LCD display peripheral initialization */
0061 3024    MOVLW  24h           wLCDctrl4(0x24);
0062 2035    CALL   0035h                 /*  Function Set-4-bit,1-line,5X7  */
0063 300C    MOVLW  0Ch           wLCDctrl4(0x0c);
0064 2035    CALL   0035h                 /*  Display on, Cursor off         */
0065 3006    MOVLW  06h           wLCDctrl4(0x06);
0066 2035    CALL   0035h                 /*  entry mode- Inc addr, no shift */
0067 3001    MOVLW  01h           wLCDctrl4(0x01);
0068 2035    CALL   0035h                 /*  Clear Display */
0069 0008    RETURN             }

                             void putcharLCD(char sci_char)
                              /* Send a character to the LCD display */
0037                            {
006A 1283    BCF    STATUS,RP0
006B 00B7    MOVWF  37
006C 300A    MOVLW  0Ah          if ((sci_char == 0x0a) ||
006D 0237    SUBWF  37,W             (sci_char == 0x0d))  /* Look for a LF */
006E 1903    BTFSC  STATUS,Z
006F 2874    GOTO   0074h
0070 300D    MOVLW  0Dh
0071 0237    SUBWF  37,W
0072 1D03    BTFSS  STATUS,Z
0073 2877    GOTO   0077h
0074 3001    MOVLW  01h            wLCDctrl4(0x01); /*  Clear Display */
0075 2035    CALL   0035h
0076 287A    GOTO   007Ah           else
0077 1283    BCF    STATUS,RP0     wLCDdat(sci_char);
0078 0837    MOVF   37,W
0079 201B    CALL   001Bh
007A 0008    RETURN              }

1996\07\23@140505 by fastfwd

face
flavicon
face
Andy Errington <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> I am using PORTA <0:3> for the LCD data port (connected to the MSB
> of the LCD data pins), and PORTB <4:6> for E, RS and R/^W.
> Obviously I am attempting to initialise the module for 4 bit
> operation.  My question is:  am I likely to have problems with PORT
> A, and should I stick everything on PORT B?
>
> This is a simple problem, I just need reassurance to keep trying.
>
> Andy (the other one)

Other Andy:

You should be fine with PORTA... Especially since you're not using
RA4.  Your problem is undoubtedly timing-related; you probably need
to slow your initialization routine WAY down, and you should be using
the LCD's "BUSY" flag for all other operations.

-Andy

Andrew Warren - fastfwdspamKILLspamix.netcom.com
Fast Forward Engineering, Vista, California
http://www.geocities.com/SiliconValley/2499

1996\07\24@054633 by Andy Errington

flavicon
face
Hi,

Many thanks to all who have responded.  I hope  the information is
useful to other PICLIST readers.

Firstly can I thank all of those who advised me about the Murata 4MHz
ceramic resonator, it's working fine, and you _can_ connect the middle
pin to +5V to simplify board layout.

Secondly the LCD module...

I tried my module on the Stamp again, which showed me it was still
working properly, and I haven't damaged it (relief!).  Back to the '84.
One problem I think I have is reading the busy flag, so I replaced that
section with a delay loop.  Now I get some life from the display.  I am
using portions of Microchips LCD application note, so my code sends 'M'
'i' 'c' 'r' 'o' 'c' 'h' 'i' 'p' to the 'Send_char' routine.  Deep joy!
On the display is some text!  Hang on, what does it say?  'Mogwognow'

I have worked out that the middle 2 bits of the lower nibble seem to be
always set to one, except for the first character (!).  Could it be that
my SWAPF function is broken inside the CPU?  I don't know,  I shall
follow people's suggestions and slow it all down some more.  More news
as it's made.

To anyone else who is using an LCD module with no success:  Take heart,
and keep trying!

Andy (the other one)

1996\07\24@101647 by Peer Ouwehand

flavicon
face
At 10:47 96/07/24 +0100, you wrote:

<<snip>>

{Quote hidden}

(Parts of the text are a reprint of some postings in februari 1996
by Scott Dattalo and myself)

Assuming you are using AN587 to write your code:
This app.note has a bug in the code to *read from* any HD44780 based LCD
module (this affects ALL read operations).

A quote of Scott's comment (4-bit LCD interface):
The proper way to perform a read operation is to:
1) Clear RS (Register Select signal on LCD Module).
2) Set R/W (Read/Write signal on LCD Module). This will select the "read"
   mode.
3) Set E (The enable bit on the LCD Module).
4) Read the 4 MSB's of the data bus on the LCD Module.
5) Clear E.
6) Set E.
7) Again, read 4 MSB's.
8) Clear E.

The two nibbles are then concatenated to form a byte. If you're reading the
busy bit, then bit 7 will reflect its state while bits 6 through 0 are either
the moste recent character or data RAM address.

The way AN587 does a read operation is:
1) Clear RS (Register Select signal on LCD Module).
2) Set R/W (Read/Write signal on LCD Module). This will select the "read"
   mode.
3) Set E (The enable bit on the LCD Module).
4) Clear E.
5) Read the 4 MSB's of the data bus on the LCD Module.
6) Set E.
7) Clear E.
8) Again, read 4 MSB's.

In other words, AN587 reverses steps 4 and 5 and steps 7 and 8. The effect is
that the LCD module gets disabled before the data is read by the PIC.
(end quote)

This bug is in both the 4-bit and 8-bit code of AN587!
A correct version of an 8-bit interface (using the 16C84 and based on AN587),
the schematics and an example (see 4.1.4. Availability) can be found at:
 http://www.iaehv.nl/users/pouweha/lcd2.htm
The code on this page makes use the busy flag successfully.
You only need delay loops during LCD initialisation.

Happy coding...

Peer.

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
       Peer Ouwehand
       .....pouwehaKILLspamspam.....iaehv.nl
       http://www.iaehv.nl/users/pouweha/

       Welcome my son, welcome to the machine. (Pink Floyd)
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

1996\07\24@122121 by rob (r.m.) mudry

flavicon
face
I had similar problems when interfacing an LCD to an 8051 controller.  Make
sure you are reading/writing data on the correct clock edge and pay close
attention to the chips timing req'ts and the timing you are generating.
Good luck.

Do you know a good source for cheap 2x16 line LCD displays?

Send reply to 'EraseMErmudryspam_OUTspamTakeThisOuTbnr.ca'  (I'm not on the list)
Thanks, Rob



In message "Re: Hitachi LCD module", you write:

{Quote hidden}

1996\07\25@050800 by Andy Errington

flavicon
face
Hi all,

well I have the LCD module working on the PIC, using delays between
characters rather than reading the busy flag.  Thanks to Peer Ouwehand
for pointing out the error of trying to read the LCD data with pin E low
(which tristates the data bus!).  I have looked through Hitachi's LCD
documentation, and this fact is not at all obvious.  However I still
cannot successfully check for the busy flag.  Most of the samples I have
seen simply tie R/^W low (always write), and use delays only.  This
means you save one I/O pin, which might be satisfactory.  I shall have
another go at reading from the LCD when I go home tonight (yes I _do_
have a home to go to).

Meanwhile I have successfully read and decoded data from a magnetic card
(a credit card in this case), and displayed it on my LCD.  I currently
ignore parity on each character, and the final parity check, but this
doesn't matter for the purposes of experimentation.  Later I shall check
parity, and then I shall attempt to decode the data with the card going
through backwards.

I hope all this drivel is of interest to someone.  It is to me.

Many thanks to all correspondents so far.

Andy (the other one)

>shameless plug<

PS I shall be seeking employment in the Yorkshire area (north of England
for our overseas readers) from January '97.  My main skills are
client/server development with VB, SQL Server and NT.  As you can see I
dabble with low level assembly, and I also have experience in access
control and security.

--
---------------------------------------------------------------------
Andrew M Errington                               Tel: +44 1524 593678
Microcomputer Consultant                         Fax: +44 1524 844011
The Computer Centre                  Mobile (Orange):     0976 243931
Lancaster University                      a.erringtonspamspam_OUTlancaster.ac.uk
Lancaster LA1 4YW     www.lancs.ac.uk/people/cpaame/cpaame.htm
---------------------------------------------------------------------
"A dog is not just for Christmas, there may be some left for
sandwiches on Boxing Day" - Vladimir Illich Ulyanov 1920

1996\07\25@053747 by fastfwd
face
flavicon
face
Andy Errington <@spam@PICLISTKILLspamspamMITVMA.MIT.EDU> wrote:

> well I have the LCD module working on the PIC, using delays
> between characters rather than reading the busy flag. .... I still
> cannot successfully check for the busy flag.  Most of the samples I
> have seen simply tie R/^W low (always write), and use delays only.
> This means you save one I/O pin, which might be satisfactory.

Other Andy:

It also means that your LCD routines will be slower than necessary,
and it prevents you from reading the display (which can be very
useful with small microcontrollers like the PIC, since it relieves
you of the burden of storing a copy of the displayed data in the
microcontroller's RAM).

It also prevents you from using the display's otherwise-unused RAM as
slow-but-plentiful external RAM for the PIC.

You haven't given enough detail for me to really diagnose your
particular problem.  Make sure, though, that you're reading all
EIGHT bits of data from the display... With your 4-bit interface,
you'll need to do TWO reads to get all the data.

Here's some sample code; it's written with the assumption that the 4
LCD data lines are tied to PORTD 4-7; SETPDI is equated to 1111xxxx
(binary) and SETPDO is equated to 0000xxxx (binary).  "PAGE0" and
"PAGE1" are simple macros that set/clear the register-page-select
bit:

;
; WAIT FOR THE LCD'S "BUSY" FLAG TO CLEAR.
;

LCDREADY:

       PAGE1                   ;SWITCH TO DATA-SEGMENT 1.

       MOVLW   SETPDI          ;MAKE THE LCD DATA BUS ALL
       MOVWF   TRISD ^ 080H    ;INPUTS.

       PAGE0                   ;SWITCH BACK TO DATA-SEGMENT 0.

LCDWTLP:

       BCF     LCDRS           ;SETUP TO READ THE BUSY FLAG.
       BSF     LCDRW           ;

       BSF     LCDE            ;CLOCK THE DATA IN.
       NOP                     ;

       MOVF    PORTD,W         ;GRAB THE HI-NIBBLE OF DATA
                               ;(BIT 7 = BUSY).

       BCF     LCDE            ;FINISH CLOCKING.

       NOP                     ;WAIT A CYCLE.

       BSF     LCDE            ;CLOCK THE LO-NIBBLE OUT (AND
       NOP                     ;IGNORE IT).
       BCF     LCDE            ;

       ANDLW   10000000B       ;MASK OFF ALL BUT THE BUSY FLAG.

       BNZ     LCDWTLP         ;IF THE LCD'S STILL BUSY, LOOP
                               ;BACK AND TRY AGAIN.

       MOVLW   00001111B       ;OTHERWISE, CLEAR THE DATA BUS.
       ANDWF   PORTD

       PAGE1                   ;SWITCH TO DATA-SEGMENT 1.

       MOVLW   SETPDO          ;MAKE THE LCD DATA BUS ALL
       MOVWF   TRISD ^ 080H    ;OUTPUTS.

       PAGE0                   ;SWITCH BACK TO DATA-SEGMENT 0.

       RETURN                  ;RETURN.

For maximum efficiency, I generally call this routine just BEFORE
performing any operation on the LCD, rather than after.

Hope this helps...

-Andy

Andrew Warren - KILLspamfastfwdKILLspamspamix.netcom.com
Fast Forward Engineering, Vista, California
http://www.geocities.com/SiliconValley/2499

1996\07\31@103306 by Sten Dahlgren

flavicon
face
On Wed, 24 Jul 1996, Andy Errington wrote:

snip

> section with a delay loop.  Now I get some life from the display.  I am
> using portions of Microchips LCD application note, so my code sends 'M'
> 'i' 'c' 'r' 'o' 'c' 'h' 'i' 'p' to the 'Send_char' routine.  Deep joy!
> On the display is some text!  Hang on, what does it say?  'Mogwognow'
>
I recognice this ! Are you using 4bit mode ? When i used the
Microchipcode i discovered that they had forgotten one of the initial
delays so that my LCD was run in 8bit mode instead.
Look for all the LCD FAQ's awailable.

---
Sten Dahlgren  CelsiusTech Systems   ! "I'd rather have 39 Hp under my arm
S-175 88 Jaerfaella      Sweden      ! than one under my backside"
RemoveMEsedaTakeThisOuTspamcelsiustech.se +46-8 58084430   ! join your nearest karting club now !!

More... (looser matching)
- Last day of these posts
- In 1996 , 1997 only
- Today
- New search...