Searching \ for '[PIC] 44780 woes' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/io/lcd/pic.htm?key=44780
Search entire site for: '44780 woes'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] 44780 woes'
2006\07\07@124056 by Bob J.

picon face
Earlier this week I started on a new project using a 16x4 LCD and a 452.
For some reason I can't seem to get the LCD initialized.  I've quadruple
checked the wiring on my breadboard, tried different PIC's, tried different
LCD's, tried different initialization strings, all to no avail.  Hopefully
its not something glaringly obvious :)

Below are some snippets of the of the initialization code.  Some of the
indenting got messed up when I pasted the code into this email.  I've tried
various combinations of delays to no avail.  I'm thinking there's a timing
issue..?  The display never turns on, I just see bars across the first and
third lines if I turn the contrast up.   If you can enlighten me I'd greatly
appreciate it.

Regards,
Bob

InitLCD
       MOVLF      4,COUNT                        ;Wait 40mS
LIL     rcall      LoopTime                      ;Call LoopTime 4 times
       decf      COUNT,F
       bnz        LIL
       bcf      PORTE,RE0                     ;RS=0 for command
       POINT      LCDstr                      ;Set up table pointer to
initialization string
       tblrd*                                 ;Get first byte from string
into TABLAT
LIL2
       bsf      PORTE,RE1                   ;Drive E high
       movff      TABLAT,PORTD                  ;Send upper nibble
        bcf      PORTE,RE1                     ;Drive E low so LCD will
process input
       rcall      T40                              ;Wait 40 uS
       bsf      PORTE,RE1                   ;Drive E high
       swapf      TABLAT,W                      ;Swap nibbles
       movwf      PORTD                         ;Send lower nibble
       bcf      PORTE,RE1                    ;Drive E low so LCD will
process input
       rcall      T40                              ;Wait 40uS
       tblrd+*                              ;Increment pointer and get next
byte
       movf      TABLAT,F                       ;Is it zero?
       bnz        LIL2
       return

;;;;;;; T40 subroutine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Pause for 40 microseconds  or 40/0.4 = 100 clock cycles.
; Assumes 10/4 = 2.5 MHz internal clock rate.

T40
       movlw      100/3                       ;Each REPEAT loop takes 3
cycles
       movwf      COUNT
LT40
       decf      COUNT,F
       bnz        LT40
       return

;;;;;;; LoopTime subroutine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; This subroutine waits for Timer0 to complete its ten millisecond count
; sequence. It does so by waiting for sixteen-bit Timer0 to roll over. To
obtain
; a period of precisely 10000/0.4 = 25000 clock periods, it needs to remove
; 65536-25000 or 40536 counts from the sixteen-bit count sequence.  The
; algorithm below first copies Timer0 to RAM, adds "Bignum" to the copy ,and
; then writes the result back to Timer0. It actually needs to add somewhat
more
; counts to Timer0 than 40536.  The extra number of 12+2 counts added into
; "Bignum" makes the precise correction.

Bignum  equ     65536-25000+12+2

LoopTime
       btfss     INTCON,TMR0IF                ;Wait until ten milliseconds
are up
       bra        LoopTime
       movff      INTCON,INTCONCOPY           ;Disable all interrupts to
CPU
       bcf      INTCON,GIEH
       movff      TMR0L,TMR0LCOPY             ;Read 16-bit counter at this
moment
       movff      TMR0H,TMR0HCOPY
       movlw      low  Bignum
       addwf      TMR0LCOPY,F
       movlw      high Bignum
       addwfc  TMR0HCOPY,F
       movff      TMR0HCOPY,TMR0H
       movff      TMR0LCOPY,TMR0L             ;Write 16-bit counter at this
moment
       movf      INTCONCOPY,W                 ;Restore GIEH interrupt
enable bit
       andlw      B'10000000'
       iorwf      INTCON,F
       bcf      INTCON,TMR0IF                 ;Clear Timer0 flag
       return

;;;;;;; Constant strings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

LCDstr  db      0x33,0x32,0x28,0x08,0x01,0x06,0x0c,0x00      ;Initialization
string for LCD

2006\07\07@125627 by David VanHorn

picon face
Second rule of LCD init debugging.. Slow down.
You covered the first, if your contrast won't get a little dark then it may
be working and you just can't see it.

2006\07\07@134336 by Bob J.

picon face
Yep, tried to slow things down and the contrast of course.  Even tried
different brands of lcds.  Hopefully I have an epiphany before I pull my
hair out.

Regards,
Bob

On 7/7/06, David VanHorn <spam_OUTdvanhornTakeThisOuTspammicrobrix.com> wrote:
>
> Second rule of LCD init debugging.. Slow down.
> You covered the first, if your contrast won't get a little dark then it
> may
> be working and you just can't see it.
> -

2006\07\07@144617 by Steve Smith

flavicon
face
part 1 821 bytes content-type:text/plain; (decoded 7bit)

There may be some useful stuff in the attached. 8 bit wide 44780 driver
(uses 7 bits for text and is reasonably optimised but it works).

Rgds steve

{Original Message removed}

2006\07\07@150115 by David VanHorn

picon face
On 7/7/06, Bob J. <.....rocketbobKILLspamspam@spam@gmail.com> wrote:
>
> Yep, tried to slow things down and the contrast of course.  Even tried
> different brands of lcds.  Hopefully I have an epiphany before I pull my
> hair out.


Boy do I know that feeling.

Are all your I/Os set up properly?
Signals actually happening at the pins?
Data connected in the right bit order?

Using a real 44780?

2006\07\07@152606 by Bob J.

picon face
On 7/7/06, David VanHorn <dvanhornspamKILLspammicrobrix.com> wrote:
>
> On 7/7/06, Bob J. <.....rocketbobKILLspamspam.....gmail.com> wrote:
> >
> > Yep, tried to slow things down and the contrast of course.  Even tried
> > different brands of lcds.  Hopefully I have an epiphany before I pull my
> > hair out.
>
>
> Boy do I know that feeling.
>
> Are all your I/Os set up properly?


Yes.

Signals actually happening at the pins?


Yes. Verified them with my logic analyzer.

Data connected in the right bit order?


Yes.  Checked it about ten times.

Using a real 44780?


Don't know.

Regards,
Bob

2006\07\07@160229 by Bob Axtell

face picon face
Can you print your code again? I erased it accidentally. But if I
recall, I saw
two things. I didn't notice the initalization code. You have to tell the
44780
what mode you wish to use, 4-bit or 8-bit. Also, I always executed the
e-clock
with the data stable on both rising and falling edges.

Can you re-submit it?

--Bob

Bob J. wrote:
{Quote hidden}

2006\07\07@161005 by Mark Scoville

flavicon
face
Hi Bob,

maybe try slowing things down a little by adding 5 or 6 nops after each
place where you change the state of the E-Clk and where you write the data
to the D port. Slow things down and stretch out the pulse width on the
E-clk. See if you observe any change - might help, might not...

I have LCD routines that have been working fine for 6+ years with various
LCDs (Can't remember all the LCD Manufactures) and Noritake, Samsung and
Futaba VFDs. I checked my code (Been 6 years don't remember what I did) and
I present the data first and then toggle the E clock. Maybe I've been doing
it wrong all these years, but it's been working. You might also try
presenting the data on PORTD first, and then clocking the E line (Present
data, few nops, E Hi, few nops, E Lo).

YMMV - Free advice, and worth every penny!

-- Mark



> {Original Message removed}

2006\07\07@162434 by Bob J.

picon face
Code reposted for Bob.

Regards,
Another Bob

InitLCD
       MOVLF      4,COUNT                        ;Wait 40mS
LIL     rcall      LoopTime                      ;Call LoopTime 4 times
       decf      COUNT,F
       bnz        LIL
       bcf      PORTE,RE0                     ;RS=0 for command

       POINT      LCDstr                      ;Set up table pointer to
initialization string
       tblrd*                                 ;Get first byte from string
into TABLAT
LIL2
       bsf      PORTE,RE1                   ;Drive E high

       movff      TABLAT,PORTD                  ;Send upper nibble
        bcf      PORTE,RE1                     ;Drive E low so LCD will
process input

       rcall      T40                              ;Wait 40 uS
       bsf      PORTE,RE1                   ;Drive E high

       swapf      TABLAT,W                      ;Swap nibbles
       movwf      PORTD                         ;Send lower nibble
       bcf      PORTE,RE1                    ;Drive E low so LCD will
process input

       rcall      T40                              ;Wait 40uS
       tblrd+*                              ;Increment pointer and get next
byte
       movf      TABLAT,F                       ;Is it zero?
       bnz        LIL2
       return

;;;;;;; T40 subroutine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Pause for 40 microseconds  or 40/0.4 = 100 clock cycles.
; Assumes 10/4 = 2.5 MHz internal clock rate.

T40
       movlw      100/3                       ;Each REPEAT loop takes 3
cycles
       movwf      COUNT
LT40
       decf      COUNT,F
       bnz        LT40
       return

;;;;;;; LoopTime subroutine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; This subroutine waits for Timer0 to complete its ten millisecond count
; sequence. It does so by waiting for sixteen-bit Timer0 to roll over. To
obtain
; a period of precisely 10000/0.4 = 25000 clock periods, it needs to remove
; 65536-25000 or 40536 counts from the sixteen-bit count sequence.  The
; algorithm below first copies Timer0 to RAM, adds "Bignum" to the copy ,and
; then writes the result back to Timer0. It actually needs to add somewhat
more
; counts to Timer0 than 40536.  The extra number of 12+2 counts added into
; "Bignum" makes the precise correction.

Bignum  equ     65536-25000+12+2

LoopTime
       btfss     INTCON,TMR0IF                ;Wait until ten milliseconds
are up
       bra        LoopTime
       movff      INTCON,INTCONCOPY           ;Disable all interrupts to
CPU
       bcf      INTCON,GIEH
       movff      TMR0L,TMR0LCOPY             ;Read 16-bit counter at this
moment
       movff      TMR0H,TMR0HCOPY
       movlw      low  Bignum
       addwf      TMR0LCOPY,F
       movlw      high Bignum
       addwfc  TMR0HCOPY,F
       movff      TMR0HCOPY,TMR0H
       movff      TMR0LCOPY,TMR0L             ;Write 16-bit counter at this
moment
       movf      INTCONCOPY,W                 ;Restore GIEH interrupt
enable bit
       andlw      B'10000000'
       iorwf      INTCON,F
       bcf      INTCON,TMR0IF                 ;Clear Timer0 flag
       return

;;;;;;; Constant strings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

LCDstr  db      0x33,0x32,0x20,0x0F,0x01,0x06,0x00      ;Initialization
string for LCD

2006\07\07@163559 by Bob J.

picon face
On 7/7/06, Mark Scoville <@spam@mscovilleKILLspamspamunicontrolinc.com> wrote:
>
> Hi Bob,
>
> maybe try slowing things down a little by adding 5 or 6 nops after each
> place where you change the state of the E-Clk and where you write the data
> to the D port. Slow things down and stretch out the pulse width on the
> E-clk. See if you observe any change - might help, might not...


I thought of the same thing, and tried both earlier today...no effect.

I have LCD routines that have been working fine for 6+ years with various
> LCDs (Can't remember all the LCD Manufactures) and Noritake, Samsung and
> Futaba VFDs. I checked my code (Been 6 years don't remember what I did)
> and
> I present the data first and then toggle the E clock. Maybe I've been
> doing
> it wrong all these years, but it's been working. You might also try
> presenting the data on PORTD first, and then clocking the E line (Present
> data, few nops, E Hi, few nops, E Lo).


I've been thinking about that too...I'll change it and give it a shot!

YMMV - Free advice, and worth every penny!


And greatly appreciated!

Regards,
Bob

2006\07\07@164423 by Jan-Erik Soderholm

face picon face
Try to change this :

>         bsf      PORTE,RE1                   ;Drive E high
>
>         movff      TABLAT,PORTD                  ;Send upper nibble
>          bcf      PORTE,RE1                     ;Drive E low

into :

>         movff      TABLAT,PORTD                  ;Send upper nibble
>         nop
>         nop
>         bsf      PORTE,RE1                   ;Drive E high
>         nop
>         nop
>          bcf      PORTE,RE1                     ;Drive E low
>         nop
>         nop

That will let the signals "calm down"...

Regards,
Jan-Erik.



2006\07\07@172355 by Bob J.

picon face
Hmmm.  Just set up the logic analyzer and nothing is happening on PORTE, RE0
and RE1 (connected to RS and E respectively).

If the E strobe isn't strobing then nothings gonna happen, not sure why
yet.  The TRISE register is set to all zeros, so I'm not sure why nothing is
showing up on the two PORTE pins I'm using.

Regards,
Bob

2006\07\07@172639 by Bob J.

picon face
ooops, I was wrong.  Sorry, never mind :).

Regards,
Bob

On 7/7/06, Bob J. <KILLspamrocketbobKILLspamspamgmail.com> wrote:
{Quote hidden}

2006\07\07@173124 by Steve Smith

flavicon
face
Make sure its set to digital not analogue

Steve

-----Original Message-----
From: RemoveMEpiclist-bouncesTakeThisOuTspammit.edu [spamBeGonepiclist-bouncesspamBeGonespammit.edu] On Behalf Of
Bob J.
Sent: 07 July 2006 22:24
To: Microcontroller discussion list - Public.
Subject: Re: [PIC] 44780 woes

Hmmm.  Just set up the logic analyzer and nothing is happening on PORTE, RE0
and RE1 (connected to RS and E respectively).

If the E strobe isn't strobing then nothings gonna happen, not sure why
yet.  The TRISE register is set to all zeros, so I'm not sure why nothing is
showing up on the two PORTE pins I'm using.

Regards,
Bob

2006\07\07@181358 by Paul James E.

picon face

Bob, If this part has A to D's, make sure they are turned off and
     that the PORTE pins are dedicated as digital I/O's.  
     If you are using a 40 pin part, I beileve PORTE contains some
     of the A to D pins.

     Just a thought.


                                              Regards,

                                                Jim



> Hmmm.  Just set up the logic analyzer and nothing is happening on
> PORTE, RE0 and RE1 (connected to RS and E respectively).
>
> If the E strobe isn't strobing then nothings gonna happen, not sure why
> yet.  The TRISE register is set to all zeros, so I'm not sure why
> nothing is showing up on the two PORTE pins I'm using.
>
> Regards,
> Bob
> --

2006\07\07@185306 by Jinx

face picon face
Bob J, this code initialises a 16x2 on an 18F452. Wiring looks
similar to yours. Speed is higher though, so amend delay loop
(or just call it 4 times per ms). I have no idea whether the LCDs
I come across are true HD44780, but this code always works.
High nybble of PortD is preserved.

#define  rs      porte,0      ;LCD RS
#define  rw      porte,1      ;LCD R/W
#define  en      porte,2      ;LCD Enable

;PortD 0-3 - LCD data

#define  busy    portd,3      ;LCD Busy flag

usec     macro                ;1us delay
        movff   temp,temp
        movff   temp,temp
        movff   temp,temp
        movff   temp,temp
        movff   temp,temp
        endm

;================================================
;        Initialise LCD screen
;================================================

lcd_init bcf    rw
        usec
        bcf    rs
        usec

        call   write30
        call   msdelay      ;delay > 4.1ms
        call   msdelay
        call   msdelay
        call   msdelay
        call   msdelay

        call   write30
        call   msdelay       ;delay > 100us

        call   write30
        call   msdelay       ;delay > 100us

;LCD settings

        movlw  b'00100000' ;
        call   write_c
        movlw  b'00001000'
        call   write_c
        movlw  b'00001100'
        call   write_c
        movlw  b'00000110'
        call   write_c
        return

write30  movfw  portd
        andlw  b'00001111'
        addlw  b'00110000'
        movwf  latd
        usec
        bsf    en
        usec
        bcf    en
        usec
        return

;===============================================
;        LCD commands
;================================================

line1    movlw  0x00          ;line 1, column 0
        call   address
        return

line2    movlw  0x40          ;line 2, column 0
        call   address
        return

address  addlw  0x80          ;set high bit of address command
        call   write_c
        return

write_c  bcf    rs            ;write command
        bra    d_out

write_d  bsf    rs            ;write data

;send 2 x 4-bits

d_out    movwf  temp          ;save data in W, and split
        swapf  temp
        movfw  portd         ;read port
        andlw  b'11110000'   ;clear LSN
        movwf  shadowd
        movfw  temp          ;add MSN to shadow reg
        andlw  b'00001111'
        addwf  shadowd,w
        movwf  latd          ;write to port
        usec
        bcf    rw
        usec
        bsf    en
        usec
        bcf    en

        movfw  portd         ;read port
        andlw  b'11110000'   ;clear LSN
        movwf  shadowd
        swapf  temp,w        ;add temp LSN to bshad
        andlw  b'00001111'
        addwf  shadowd,w
        movwf  latd          ;write to port
        usec
        bcf    rw
        usec
        bsf    en
        usec
        bcf    en

        usec
        bsf    rw            ;set LCD RW for Read
        usec
        bcf    rs

        mov    b'00001000',trisd ;Busy as i/p
        bsf    en
rdbusy   btfsc  busy          ;loop until Busy Flag clear
        bra    rdbusy
        bcf    en
        usec
        bcf    rw
        mov    b'00000000',trisd

        return

;================================================
;        Delays, Fosc = 39.3216MHz
;================================================

;1ms delay - call 100us delay 10 times

msdelay  movlw  0xf6
        movwf  cnt1
next100  call   usdelay       ;enter here with number of 100us in cnt1
        incfsz cnt1
        goto   next100
        return

;100us delay

usdelay  movlw  0xa7
        movwf  cnt2
inc      movff  temp,temp
        movff  temp,temp
        movff  temp,temp
        movff  temp,temp
        incfsz cnt2
        bra    inc
        return

2006\07\07@215601 by Bob J.

picon face
Gents, thanks for the help, I figured out what my problems were.  The most
<cough, gasp> glaring one was leaving the R/W line floating on the LCD.  My
initialization string was wrong, and my subroutine to display constant
strings had some issues.

Regards,
Bob

2006\07\07@224127 by Bob Barr

flavicon
face
On Fri, 7 Jul 2006 21:55:59 -0400, "Bob J." wrote:

>Gents, thanks for the help, I figured out what my problems were.  The most
><cough, gasp> glaring one was leaving the R/W line floating on the LCD.  My
>initialization string was wrong, and my subroutine to display constant
>strings had some issues.
>

But other than that, everything was fine, right? :=)

Reminds me of: So, other than that, Mrs. Lincoln, how was the play?


Regards, Bob

2006\07\08@040341 by Steve Smith

flavicon
face
It took me 3 days about 10 yrs ago to make one of them work got it working
faster with 9 switches and a pushbutton. Persistence!

Steve

{Original Message removed}

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