The Godfather talking
You may crack software. How about me?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 29, 2024, 04:03:59 16:03


Login with username, password and session length


Pages: [1]
Print
Author Topic: LCD not working  (Read 2977 times)
0 Members and 1 Guest are viewing this topic.
smoogy
Newbie
*
Offline Offline

Posts: 14

Thank You
-Given: 9
-Receive: 0


« on: November 18, 2007, 12:02:55 00:02 »

I found two routines from different books to start working with an LCD. The first one (at LCD.asm) works on PROTEUS but not physically. The second one (at LCD3.asm) works nowhere but is supposed to. Can anyone help me fix the routines I've got or give me one in assembly language that actually works?

1-Vss (GND)
2-Vdd (5V)
3-Vss (GND)
4-RB6
5-Vss (GND)
6-RB5
7 to 14 - RB0 to RB7
Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #1 on: November 18, 2007, 02:24:05 02:24 »

Really need more information from you as to what you need the LCD to display (like data coming in from another device or a sensor), what PIC, or processor you are using, what kind of LCD display you have like a 2 line x 16 character device. Do you have a proteus project you can upload to let people see what it is you are trying to do?
I'm also working with an LCD display. 4x20 and my code works great but having some difficulties with checking the Busy Flag. Right now it works perfect with hardcoded delays. Data arrives via RS232 from a GPS module and then the NEMA sentences are parsed and sent to my LCD display. There are a few examples on the internet which helped me out do this. Would be glad to help you but really need more information from you.

Alienbeing
Logged
smoogy
Newbie
*
Offline Offline

Posts: 14

Thank You
-Given: 9
-Receive: 0


« Reply #2 on: November 18, 2007, 03:34:29 03:34 »

Hi Alienbeing. I'm working with a PIC16F877 and a 16x2 LCD (I bought it for 3 USD, but I kwow for sure it works). At this moment I'm only testing the LCD to view anything on it. After that, I'm planning to display on it the value from an LM35. I can only upload the PROTEUS file I'm currently using due to an error caused by a lack in the model of the final application. Nevertheless, I can also upload the file I wrote to display the whole thing. Let me know if you can see the attachments. I did include some of them on my first post.
Logged
Alienbeing
Active Member
***
Offline Offline

Posts: 164

Thank You
-Given: 68
-Receive: 45


« Reply #3 on: November 18, 2007, 05:03:36 05:03 »

OK, I'll take a look. It's kind of late right now. Bed time.... US east coast.... so, I probably won't get back to you about it until tomorrow sometime.
Logged
user112
Junior Member
**
Offline Offline

Posts: 85

Thank You
-Given: 6
-Receive: 139


Salut tuturor(hello to all)


« Reply #4 on: November 18, 2007, 06:11:28 06:11 »

hello I have this project with LCD and works maybe it will help you with something
Logged
smoogy
Newbie
*
Offline Offline

Posts: 14

Thank You
-Given: 9
-Receive: 0


« Reply #5 on: November 18, 2007, 03:23:41 15:23 »

It's working! It seems the problem was the routine to start the LCD. When I'm done with my project I'll upload the files.
Logged
localcrack
Active Member
***
 Muted
Offline Offline

Posts: 173

Thank You
-Given: 64
-Receive: 21



« Reply #6 on: November 18, 2007, 05:24:02 17:24 »

I have code for 8051, It is well commented so you can easily modify for PIC


; This program is to test lcd display using 8051 prototype board
; Demo Program Scrolling continues
;P1=data pin
;P2.0 connected to RS pin
;P2.1 connected to R/W pin
;P2.2 connected to E pin
       

   ;call delay1
   MOV     A,#38H   ;init. LCD 2 lines,5x7 matrix
        ACALL   COMMAND       ;issue command
        MOV     A,#0EH        ;LCD on, cursor on
        ACALL   COMMAND       ;issue command
        MOV     A,#01H        ;clear LCD command
        ACALL   COMMAND       ;issue command
        MOV     A,#06H        ;shift cursor right
        ACALL   COMMAND       ;issue command
   MOV     A,#0C0H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'8'        ;display letter N
        ACALL   DATA_DISPLAY   
        MOV     A,#'0'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'5'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'1'        ;display letter O   
   ACALL   DATA_DISPLAY           
        MOV     A,#'D'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'E'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'M'        ;display letter O   
        ACALL   DATA_DISPLAY
   MOV     A,#'O'        ;display letter O
   ACALL   DATA_DISPLAY
   

   MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'4'        ;display letter N
        ACALL   DATA_DISPLAY   
   CALL DELAY
   MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'3'        ;display letter N
        ACALL   DATA_DISPLAY      
   CALL DELAY
   MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
   
        MOV     A,#'2'        ;display letter N
        ACALL   DATA_DISPLAY   
   CALL DELAY
   MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
   
        MOV     A,#'1'        ;display letter N
        ACALL   DATA_DISPLAY   
   CALL DELAY
   MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
   
        MOV     A,#'0'        ;display letter N
        ACALL   DATA_DISPLAY      
   CALL DELAY   

   MOV     A,#01H        ;clear LCD command
        ACALL   COMMAND       ;issue command
;----------------------------------------------------------------------------------------------
   
   
   
   MOV     A,#0C0H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'8'        ;display letter N
        ACALL   DATA_DISPLAY   
        MOV     A,#'0'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'5'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'1'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#' '        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'L'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'C'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'D'        ;display letter O
   ACALL   DATA_DISPLAY
   MOV     A,#' '        ;display letter O       
        ACALL   DATA_DISPLAY
   MOV     A,#'D'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'I'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'S'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'P'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'L'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'A'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'Y'        ;display letter O
        ACALL   DATA_DISPLAY   
   MOV     A,#' '        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'8'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'0'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'5'        ;display letter O
        ACALL   DATA_DISPLAY
    MOV     A,#'1'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#' '        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'D'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'E'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'V'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'O'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'L'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'O'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'P'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'M'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'E'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'N'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'T'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'-'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'B'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'O'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'A'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'R'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'D'        ;display letter O
        ACALL   DATA_DISPLAY
;----------------------------------------------------------------------------


   MOV     A,#85H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'N'        ;display letter N
        ACALL   DATA_DISPLAY   
        MOV     A,#'S'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'K'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#' '        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'E'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'L'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'E'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'C'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'T'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'R'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'0'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'N'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'1'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'C'        ;display letter O
        ACALL   DATA_DISPLAY
   MOV     A,#'S'        ;display letter O
        ACALL   DATA_DISPLAY
   
   

HERE:   MOV     A,#18H        ;cursor: line 1, pos. 6
        ACALL   COMMAND
   CALL DELAY1
   
   lJMP HERE 
 
                      ;STAY HERE
COMMAND: ACALL   READY        ;is LCD ready?
        MOV     P1,A          ;issue command code
        CLR     P2.0          ;RS=0 for command
        CLR     P2.1          ;R/W=0 to write to LCD
        SETB    P2.2          ;E=1 for H-to-L pulse
        CLR     P2.2          ;E=0 ,latch in
        RET
DATA_DISPLAY:
        ACALL   READY         ;is LCD ready?
        MOV     P1,A          ;issue data 
        SETB    P2.0          ;RS=1 for data
        CLR     P2.1          ;R/W=0 to write to LCD
        SETB    P2.2          ;E=1 for H-to-L pulse
        CLR     P2.2          ;E=0, latch in
        RET

READY:
     SETB    P1.7             ;make P1.7 input port
     CLR     P2.0        ;RS=0 access command reg
     SETB    P2.1        ;R/W=1 read command reg
BACK:CLR     P2.2        ;E=1 for H-to-L pulse
     SETB    P2.2        ;E=0 H-to-L pulse
     JB      P1.7,BACK        ;stay until busy flag=0
     RET

delay:
mov r7, #0fh
up4: mov r6, #060h
up3: mov r5, #00h
djnz r5, $
djnz r6, up3
djnz r7, up4
ret



;-------------------delay program------------------------         
DELAY1:
                
     MOV  TMOD,#010H     
          MOV  R3,#04H               ;95       
TES:      MOV  TL1,#00H               ;00       
          MOV  TH1,#00H               ;00       
          SETB TR1           
T  :      JNB  TF1,T 
          CLR  TR1           
     CLR  TF1                           
          DJNZ R3,TES
          RET
;---------------------end-------------------------------------                 

END                  
Logged
Trishool
Active Member
***
Offline Offline

Posts: 113

Thank You
-Given: 9
-Receive: 9



« Reply #7 on: November 21, 2007, 02:58:12 14:58 »

It's working! It seems the problem was the routine to start the LCD. When I'm done with my project I'll upload the files.

Smoogy , its nice , but why dont you us it in 4-bit bus mode?? , its too simple this way.

TS
« Last Edit: December 01, 2007, 08:09:09 08:09 by Trishool » Logged
Bart
Guest
« Reply #8 on: November 30, 2007, 12:10:51 00:10 »

I just finished prototyping an 18f1220/1330 to be used in a serial lcd,,,I am now redoing it to use different pin assignments
to allow easier pcb layout....its in C used with cc8e compiler..

I also finally got 12f683 [nicd battery charger] chip using 2 wires to  74c164 to drive a 4x16 lcd...
I went through a lot of aggrevation before getting the 74c164 4 bit interface working.........it's not as
easiy as some articles imply [ie] beware spurious clocks....programed in MikroBasic..

Logged
donat
Guest
« Reply #9 on: December 05, 2007, 05:22:40 17:22 »

Hi i'm using this code.. It may help you for 4-bit mode

'***************************************************************'
'********              LCD initialisatie                ********'
'***************************************************************'
    pause 200                       'tijdsvertraging display' 
               
    DEFINE LCD_DREG PORTD            'datapoort selecteren'
    DEFINE LCD_DBIT 0                'beginnende databit selecteren'
    DEFINE LCD_RSREG PORTA           'lcd register poort selecteren'
    DEFINE LCD_RSBIT 3               'register select bit'
    DEFINE LCD_EREG PORTA            'enable poort'
    DEFINE LCD_EBIT 1                'enable bit'
    DEFINE LCD_BITS 4                'lcd bus size'
    DEFINE LCD_LINES 2               'lcd lijnen'
    DEFINE LCD_COMMANDUS 2000        'commandovertraging in µs'
    DEFINE LCD_DATAUS 50             'data vertraging in µs'

'***************************************************************'
'*******            Declaratie van variabelen            *******'
'***************************************************************'

    LED1    VAR     PortB.3             ' led op poort  RB3 = LED1
    LED2    VAR     PortB.2             ' led op poort  RB2 = LED2
    LED3    VAR     PortB.1             ' led op poort  RB1 = LED3
    LED4    VAR     PortB.0             ' led op poort  RB0 = LED4


'***************************************************************'
'*******           Special function registers            *******'
'***************************************************************'


TRISA   = %00000001           ' 1 = input
TRISB   = %00000000           ' 1 = input  0 = output
TRISD   = %00000000


'***************************************************************'
'*******                  main program                   *******'
'***************************************************************'

main:           
                pause 200
                LCDOUT $FE,1                ' clear LCD
                pause 200                   ' pauze 0,1s
                LCDOUT $FE,2                ' cursor home
                pause 200
               
                LCDOUT $FE, $80, "     HELLO      "
                LCDOUT $FE, $C0, "     WORLD      "   
                PAUSE 200
               
                goto main
               
END

Greets D.
Logged
pici192
Guest
« Reply #10 on: December 21, 2007, 12:37:28 12:37 »

First and first what is the LCD type?
Which one the chip on the LCD backround?
You need to set up the LCD before using!
Like 4-8 bus mode, caracter set, line set and etc,etc.
Logged
o_cientista
Newbie
*
Offline Offline

Posts: 9

Thank You
-Given: 1
-Receive: 4


« Reply #11 on: February 07, 2008, 04:14:31 16:14 »

Good night, friend!
This document can also help you
http://www.intech-lcd.com/image/Product_LCD_Module/interfacetompu.pdf
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC