• AVR Freaks

Hot!can't initialize the LCD ST7066U

Author
SneaKSz
Starting Member
  • Total Posts : 41
  • Reward points : 0
  • Joined: 2010/08/12 03:29:16
  • Location: The coast
  • Status: offline
2010/08/15 04:20:39 (permalink)
0

can't initialize the LCD ST7066U

Hello,

I'm trying to initialize my new LCD ST7066U(POWERTIP CORP PC1602ARU-HWB-G-Q ) . I've programmed my PIC18F14K50 for over 20 times but I can't get the display ON .


Datasheet  LCD : http://www.farnell.com/datasheets/40247.pdf


I first initialise by using the function set , then the cursor or display shift and finally turn the display on .


   ;******************************************************************************   
 ;                            
 ;******************************************************************************
 ;                                                                             *
 ;    Filename: LCD                                                            *
 ;    Date: 15/08/10                                                                   *
 ;    File Version:                                                            *
 ;                                                                             *
 ;    Author: CJ                                                              *
 ;    Company:                                                                 *
 ;                                                                             *
 ;******************************************************************************
 ;                                                                             *
 ;    Files required: P18F14K50.INC     //1330.INC                                             *
 ;                                                                             *
 ;******************************************************************************
     LIST P=18F14K50, F=INHX32 ;directive to define processor and file format
     #include <P18F14K50.INC>     ;processor specific variable definitions
 
 ;******************************************************************************

 CONFIG    CPUDIV = NOCLKDIV;
 CONFIG    USBDIV = OFF ;
 CONFIG    FOSC = HS;
 CONFIG    PLLEN = OFF;
 CONFIG    FCMEN = OFF;
 CONFIG    IESO = OFF;
 CONFIG    PWRTEN = ON;
 CONFIG    BOREN = ON;
 CONFIG    BORV = 30;
 CONFIG    WDTEN = OFF;
 CONFIG    WDTPS = 1;
 CONFIG    MCLRE = ON;
 CONFIG    HFOFST = ON;
 CONFIG    STVREN = ON;
 CONFIG    LVP = OFF;
 CONFIG    BBSIZ = OFF;
 CONFIG    XINST = OFF;
 CONFIG    CP0 = ON;
 CONFIG    CPB = ON;
 CONFIG    CPD = ON;
 CONFIG    WRT1= ON;
 CONFIG    WRTB = ON;
 CONFIG    WRTC = ON;
 CONFIG    WRTD = ON;
 CONFIG    EBTRB = ON;
 
 
 
 ;------------------------------------------------------------------------------
 ; MAIN PROGRAM
 ;------------------------------------------------------------------------------

    cblock  0x20 
    r1             ; delay
    r2            
    r3        
    delay2    ; amount of delay
    endc


; R/W\ ==> GND write always

#define  EN   PORTB,6
#define  RS   PORTB,7
#define  DB0  PORTC,0
#define  DB1  PORTC,1
#define  DB2  PORTC,2
#define  DB3  PORTC,3
#define  DB4  PORTC,4
#define  DB5  PORTC,5
#define  DB6  PORTC,6
#define  DB7  PORTC,7



          ORG    0x00   
          call init
start     call initlcd
       
 
init     clrf TRISC
        clrf PORTC
        bcf ADCON0,ADON ; disable ana input
         MOVLW 0F0h
        movwf TRISB
        clrf PORTB
        clrf r1
        clrf r2
        clrf r3
        clrf delay2
        clrf WPUB ; disable weak pull-up
       

        return
              
initlcd  ; wait 15ms to start the LCD
        movlw 0x96 ;( 150 dec) 150*100µs=15ms
        movwf delay2
        call delay
        bcf RS ; RS low
        bcf EN ; EN low   
    ;=================Set Function==================

; DL = interface 8 bits  , NL = 2 , F = 5*11       


        MOVLW 38h
        movwf PORTC
        call enwait ; 1,5 ms wachten

    ; wait 15ms to start the next instruction
        movlw 0x96 ;( 150 dec) 150*100µs=15ms
        movwf delay2
        call delay
    ;==========================shift=======================
   
    ;     14h   cursor move, shift right

        movlw 14h
        movwf PORTC
        call enwait

    ;===========Display On/Off control======================

        ;MOVLW 0Fh           ;display ON, cursor ON, cursor flash
        ; MOVLW 0Ch             ; display ON, cursor OFF, cursor flash

        movlw 0x0f
        movwf PORTC
        call enwait

;Clear display   

    ;    bcf RS ; RS low
    ;    bcf RW ; R/W low

    ;    MOVLW 0x96 ; Clear commando
    ;    movwf PORTC
    ;    call enwait       

; return home
        MOVLW 0x02
        movf  PORTC
        call enwait       


        call figure
        return

figure    bsf RS
        MOVLW 40h
        movwf PORTC
        call enwait
        goto figure
        return

enwait
        bsf  EN ; EN high
        movlw 0x0f ; wait 1,5 ms 
        movwf delay2
        call delay
        bcf  EN ; EN low
        return

delay   movlw   0x0A  ; delay2*10²*3*333ns=100µs*delay= delay2*100µs
        movwf    r1           
D3        movlw    0x0A
        movwf    r2           
D4        movff   delay2,r3
D5        decfsz   r3,f ; 333ns                                
        goto     D5   ; 666ns
        decfsz   r2,f                             
        goto     D4                 
        decfsz   r1,f               
        goto     D3   
        return            
 ;******************************************************************************
 ;End of program
 
         END


The display never went on . I don't know what I'm doing wrong .


Can someone please have a look at this and try to help me with what I do wrong?

Thanks in advance.




post edited by SneaKSz - 2010/08/15 17:40:54
#1

13 Replies Related Threads

    SneaKSz
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2010/08/12 03:29:16
    • Location: The coast
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/15 12:48:11 (permalink)
    0
    I've checked every connection in hardware , its all connected and supplied . It can only be the asm . Can someone please look at the code?

    Thanks
    #2
    Mike017
    Super Member
    • Total Posts : 2698
    • Reward points : 0
    • Joined: 2007/08/25 08:11:31
    • Location: Lincoln, RI, USA
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/15 15:33:31 (permalink)
    0
    Hi,
     
    I've checked every connection in hardware , its all connected and supplied . It can only be the asm . Can someone please look at the code?
    Let's start with PORTC. You are using some PORT C pins. Is there code to disable analog function on them?
     
    Good Luck,
    Mike
    post edited by Mike017 - 2010/08/15 15:48:03
    #3
    violin
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2005/05/09 04:59:48
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/15 15:52:01 (permalink)
    0
    I've checked every connection in hardware , its all connected and supplied . It can only be the asm . Can someone please look at the code?

    Sorry but your code has absolutely no resemblance to the initialization of any LCD, Samsung or Hitachi, 8-bit or 4-bit mode. I have posted many asm LCD example LCD programs here if you care to search for them, - although only in 4-bit mode and for Hitachi HD44780 controller only. Sorry again and regards.
    #4
    SneaKSz
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2010/08/12 03:29:16
    • Location: The coast
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/15 17:02:47 (permalink)
    0
    Mike017
    Hi,
     
    I've checked every connection in hardware , its all connected and supplied . It can only be the asm . Can someone please look at the code?
    Let's start with PORTC. You are using some PORT C pins. Is there code to disable analog function on them?
      Good Luck,
    Mike


    Hello Mike ,

    I thought this would do the trick :
     
     init     clrf TRISC  
             clrf PORTC

    I also disabled the ADC

             bcf ADCON0,ADON

    Greets


    post edited by SneaKSz - 2010/08/15 17:06:24
    #5
    SneaKSz
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2010/08/12 03:29:16
    • Location: The coast
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/15 17:45:30 (permalink)
    0
    violin

    I've checked every connection in hardware , its all connected and supplied . It can only be the asm . Can someone please look at the code?

    Sorry but your code has absolutely no resemblance to the initialization of any LCD, Samsung or Hitachi, 8-bit or 4-bit mode. I have posted many asm LCD example LCD programs here if you care to search for them, - although only in 4-bit mode and for Hitachi HD44780 controller only. Sorry again and regards.


    Hello violin , thanks for the reaction , it's the first time i work with a LCD display.

    Ive looked into your green picdem2  asm files. You use a table to initialise your LCD !
    #6
    violin
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2005/05/09 04:59:48
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/16 02:33:44 (permalink)
    0
    Ive looked into your green picdem2  asm files. You use a table to initialise your LCD !

    Yes, but not all the time, depends in how I am feeling. - Athough there is nothing wrong in using tables for LCD initialization.
     
    I am somewhat reluctant to get further involved with your difficulty because my feeling is that your using an Samsung controller in which I have absolutely no experience with as I know there timings differ somewhat with the Hitachi controllers in which I am familiar with. Sorry and regards
    [size=3 font="times new roman"] 
     
    #7
    SneaKSz
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2010/08/12 03:29:16
    • Location: The coast
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/16 03:43:32 (permalink)
    0
    Thanks for the reaction violin,

    well if you take a look at the datasheet at page 9, you can see the time delay's. There is even  no start up time.

    Maybe you can help me with the following :  I dont understand the sequence of initialising the LCD.  Some people use first the "function set" , then " display on /off" and then " cursor / display shift" . I've also seen programs that switch these last 2 ( that hitachi controller ).

    My question is how can the LCD now know for what function the instruction is meant?


    I've got the display working , the first row are black bars. Someone knows what this means? Thanks

    Thanks


    post edited by SneaKSz - 2010/08/16 08:54:45
    #8
    violin
    Super Member
    • Total Posts : 3301
    • Reward points : 0
    • Joined: 2005/05/09 04:59:48
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/16 09:23:12 (permalink)
    0
    I've got the display working , the first row are black bars. Someone knows what this means? Thanks

    No you haven't,- all you manage to do is to get the LCD to power-up successfully. It's a start I suppose Smile

    This link may help you a bit further in your LCD understanding.
    post edited by violin - 2010/08/16 09:34:22
    #9
    frankcf1
    Super Member
    • Total Posts : 1105
    • Reward points : 0
    • Joined: 2009/01/09 08:20:10
    • Location: Northern New Jersey
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/16 09:56:30 (permalink)
    0
    Look at the datasheet here http://www.newhavendisplay.com/app_notes/ST7066.pdf
    Pages 20 and 21 have the proper init sequence.
    #10
    SneaKSz
    Starting Member
    • Total Posts : 41
    • Reward points : 0
    • Joined: 2010/08/12 03:29:16
    • Location: The coast
    • Status: offline
    Re:can't initialize the LCD ST7066U 2010/08/16 10:36:25 (permalink)
    0
    frankcf1

    Look at the datasheet here http://www.newhavendisplay.com/app_notes/ST7066.pdf
    Pages 20 and 21 have the proper init sequence.


    Hello ,

    thanks for the PDF (ST7066 , I have the ST7066U , but used the initialisation), I applied it in ASM code :

      ;******************************************************************************
     ;                            
     ;******************************************************************************
     ;                                                                             *
     ;    Filename: LCD                                                            *
     ;    Date: 15/08/10                                                                   *
     ;    File Version:                                                            *
     ;                                                                             *
     ;    Author: CJ                                                              *
     ;    Company:                                                                 *
     ;                                                                             *
     ;******************************************************************************
     ;                                                                             *
     ;    Files required: P18F14K50.INC     //1330.INC                                             *
     ;                                                                             *
     ;******************************************************************************
         LIST P=18F14K50, F=INHX32 ;directive to define processor and file format
         #include <P18F14K50.INC>     ;processor specific variable definitions
     
     ;******************************************************************************

     CONFIG    CPUDIV = NOCLKDIV;
     CONFIG    USBDIV = OFF ;
     CONFIG    FOSC = HS;
     CONFIG    PLLEN = OFF;
     CONFIG    FCMEN = OFF;
     CONFIG    IESO = OFF;
     CONFIG    PWRTEN = ON;
     CONFIG    BOREN = ON;
     CONFIG    BORV = 30;
     CONFIG    WDTEN = OFF;
     CONFIG    WDTPS = 1;
     CONFIG    MCLRE = ON;
     CONFIG    HFOFST = ON;
     CONFIG    STVREN = ON;
     CONFIG    LVP = OFF;
     CONFIG    BBSIZ = OFF;
     CONFIG    XINST = OFF;
     CONFIG    CP0 = ON;
     CONFIG    CPB = ON;
     CONFIG    CPD = ON;
     CONFIG    WRT1= ON;
     CONFIG    WRTB = ON;
     CONFIG    WRTC = ON;
     CONFIG    WRTD = ON;
     CONFIG    EBTRB = ON;
     
     
     
     ;------------------------------------------------------------------------------
     ; MAIN PROGRAM
     ;------------------------------------------------------------------------------


        cblock  0x20 
        r1             ; delay
        r2            
        r3        
        delay2    ; amount of delay
        fourt   ; 4 times execute a loop
        ctemp
        endc


    ; R/W\ ==> GND write always

    #define  EN   PORTB,6
    #define  RS   PORTB,7
    #define  DB0  PORTC,0
    #define  DB1  PORTC,1
    #define  DB2  PORTC,2
    #define  DB3  PORTC,3
    #define  DB4  PORTC,4
    #define  DB5  PORTC,5
    #define  DB6  PORTC,6
    #define  DB7  PORTC,7



              ORG    0x00   
              call init
    start     call initlcd
            ;  call figure
           
     
    init     clrf TRISC
            clrf PORTC
            bcf ADCON0,ADON
             MOVLW 0F0h
            movwf TRISB
            clrf PORTB
            clrf r1
            clrf r2
            clrf r3
            clrf delay2
            clrf WPUB
            movlw 0x04
            movwf fourt
            clrf ctemp ; temp register to send data to PORTC
           

            return
                  
    initlcd  ; wait 150ms to start the LCD
            movlw 0x0f ;( 15 dec) 15*10ms=150ms
            movwf delay2
            call delaylong
            bcf RS ; RS low
            bcf EN ; EN low   
        ;=================Set Function==================
    ; execute 4 times with equal delay

    ; DL = interface 8 bits  , NL = 2 , F = 5*11       
    again     MOVLW 38h ;
            movwf ctemp
            call enwait ; 5ms wait

        ; wait 15ms to start the next instruction
            movlw 0x96 ;( 150 dec) 150*100µs=15ms
            movwf delay2
            call delay
            decfsz fourt,f
            goto again
    ; display off
            movlw b'00111000'
            movwf ctemp
            call enwait   
            movlw 0x01 ; 1*100µs=100µs
            movwf delay2
            call delay       
    ;Clear display   
            MOVLW 0x01 ; Clear commando
            movwf ctemp
            call enwait       
            movlw 0x01 ; 1*100µs=100µs
            movwf delay2
            call delay
    ; entry mode set
            MOVLW 0x07 ; I/D high and shift on
            movwf ctemp
            call enwait               
            movlw 0x01 ; 1*100µs=100µs
            movwf delay2
            call delay   
            return
    ; display on , cursur on , blinking
            MOVLW 0x0F ;
            movwf ctemp
            call enwait               
            movlw 0x01 ; 1*100µs=100µs
            movwf delay2
            call delay   
            return
    ; return home
            MOVLW 0x02 ;
            movwf ctemp
            call enwait               
            movlw 0x01 ; 1*100µs=100µs
            movwf delay2
            call delay   
            loop    goto loop
            return
           

    figure    bsf RS
            MOVLW 40h
            movwf ctemp
            call enwait
            return


    enwait
            bsf  EN ; EN high
            call endelay
            movf ctemp,w
            movwf PORTC
            bcf  EN ; EN low
            call endelay
            return

    endelay movlw 0x32 ; wait 5 ms 
            movwf delay2

    delay   movlw   0x0A  ; delay2*10²*3*333ns=100µs*delay= delay2*100µs
            movwf    r1           
    D3        movlw    0x0A
            movwf    r2           
    D4        movff   delay2,r3
    D5        decfsz   r3,f ; 333ns                                
            goto     D5   ; 666ns
            decfsz   r2,f                             
            goto     D4                 
            decfsz   r1,f               
            goto     D3   
            return       

    delaylong  movlw   0x64  ; delay2*100²*3*333ns=100µs*delay= delay2*10ms
            movwf    r1           
    C3        movlw    0x64
            movwf    r2           
    C4        movff   delay2,r3
    C5        decfsz   r3,f ; 333ns                                
            goto     C5   ; 666ns
            decfsz   r2,f                             
            goto     C4                 
            decfsz   r1,f               
            goto     C3   
            return   

        
     ;******************************************************************************
     ;End of program
     
             END


    if you look at the PDF ,at page 20 of the PDF , it says that the display needs to be turned off with ' 00111000" , but I think that instruction doesn't refer to that function.

    Violin , thanks for the link !



    post edited by SneaKSz - 2010/08/16 14:58:46
    #11
    didierleplae
    Junior Member
    • Total Posts : 101
    • Reward points : 0
    • Joined: 2019/03/31 16:57:50
    • Location: 0
    • Status: offline
    Re: can't initialize the LCD ST7066U 2019/11/19 01:01:08 (permalink)
    0
    SneaKSz
    Hello,

    I'm trying to initialize my new LCD ST7066U(POWERTIP CORP PC1602ARU-HWB-G-Q ) . I've programmed my PIC18F14K50 for over 20 times but I can't get the display ON .



    Did you ever figure this out? I'm having a similar issue. I know this was 9 years ago, haha, so maybe you don't remember or even care anymoregrin: grin!


    #12
    ric
    Super Member
    • Total Posts : 24638
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: can't initialize the LCD ST7066U 2019/11/19 01:15:55 (permalink)
    0
    So rather than respond in your own topic, which is getting answers, you resurrect a 9 year old topic full of clueless responses...
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #13
    didierleplae
    Junior Member
    • Total Posts : 101
    • Reward points : 0
    • Joined: 2019/03/31 16:57:50
    • Location: 0
    • Status: offline
    Re: can't initialize the LCD ST7066U 2019/11/19 16:44:25 (permalink)
    0
    ric
    So rather than respond in your own topic, which is getting answers, you resurrect a 9 year old topic full of clueless responses...



    Ha, you're right. Just came across  this while looking for some answers. Looked like what they were going through was so similar to what I am.
     
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5