Searching \ for ' Initialising an HD44780 compatible LCD' 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: 'Initialising an HD44780 compatible LCD'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] Initialising an HD44780 compatible LCD'
2002\03\02@130348 by Haris I. Volos

flavicon
Hi!

I am a beginner in PIC and I have built a specific circuit that features a
16x2 LCD which is connected to a 16F877 pic running at 4MHz. The data
bits(DB4-7) are connected to the Lower nibble of PORTB(0:3) and the control
lines to PORTE, RE0 to E, RE1 to R/W and RE2 to RS. As you might already
realize I want to use the LCD in the 4bit mode. The Higher nibble of port B
will be used as inputs

I have spend hours of reading datasheets, internet pages how to use the lcd
and I didn't see light to the tunnel. I have also tried to use ready made
routines but because they were abstracts from largest projects I didn't
manage to so modify them in order to make my lcd to work.

I would be grateful if you can sent me the minimal code required to just
display a single character on the LCD to verify that is working, also that
will give me a very good starting point to proceed further my own to
implement more complicated functions of the LCD.

Thanks in advance,

Haris Volos
Electrical Eng. Student

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\03\02@130904 by Haris I. Volos

flavicon
Hi!
I am a beginner in PIC and I have built a specific circuit(my design) that
features a
16x2 LCD which is connected to a 16F877 pic running at 4MHz. The data
bits(DB4-7) are connected to the Lower nibble of PORTB(0:3) and the control
lines to PORTE, RE0 to E, RE1 to R/W and RE2 to RS. As you might already
realize I want to use the LCD in the 4bit mode. The Higher nibble of port B
will be used as inputs

I have spend hours of reading datasheets, internet pages how to use the lcd
and I didn't see light to the tunnel. I have also tried to use ready made
routines but because they were abstracts from largest projects I didn't
manage to so modify them in order to make my lcd to work.

I would be grateful if you can sent me the minimal code required to just
display a single character on the LCD to verify that is working, also that
will give me a very good starting point to proceed further my own to
implement more complicated functions of the LCD.

Thanks in advance,

Haris Volos
Electrical Eng. Student

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2002\03\02@132520 by dpharris

picon face
Haris-

You should be able to adapt the code to your uses.  Remember, you have to
initialize the LCD so that it will recognise nibble commands, this requires the
initialization code, and the specific order is important.  The other thing that
messes people up is the bias for the display.  Different displays need
different biases, so it is good to adjust this until you can see the LCD
working.
Here is some generic code for the Piclist archives:
http://www.piclist.com/techref/microchip/4bitlcd.src  --- looks like you would
have to do some (major) renovations here, but check out the other code at:
http://www.piclist.com/techref/microchip/ios.htm.

Also, send your present code to the list, and we can help you get it going.

David

"Haris I. Volos" wrote:

{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2002\03\02@154555 by Jeff DeMaagd

flavicon
face
There is some code in C and ASM at piclist.com that did the trick for
me.  You may have to change the IO ports to make it work on your chip, but
with minor tweaks, I've gotten it to work on PIC16F84's, F872's and F877's.

I too struggled with data sheets, several LCD data sheets that I've come
across were flat-out wrong.

Jeff

At 08:07 PM 3/2/02 +0200, you wrote:
>I would be grateful if you can sent me the minimal code required to just
>display a single character on the LCD to verify that is working, also that
>will give me a very good starting point to proceed further my own to
>implement more complicated functions of the LCD.

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2002\03\02@160752 by Nick Veys

flavicon
face
I've gotten it working on a F870 if you'd like the code.  Couldn't get
it to work in a 628 when I tried it a few months ago (but only gave it
about an hour of time ;) )  Even got a plethora (yes, a plethora) for
macro functions for the 870 written to do spiffy stuff.

nickspamspam_OUTveys.com | http://www.veys.com/nick

> At 08:07 PM 3/2/02 +0200, you wrote:
> I would be grateful if you can sent me the minimal code required to
> just display a single character on the LCD to verify that is
> working, also that will give me a very good starting point to proceed
> further my own to implement more complicated functions of the LCD.

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2002\03\03@042918 by Benjamin Bromilow

flavicon
face
It's worth noting that "compatible" is a broad word. Init code varies from
driver to driver and although they roughly follow the HD44780 rules, doing a
general HD44780 init can still prevent the unit from working. Check which
driver IC is used and download the datasheet for that. Many give the 4-bit
init sequence...

Ben

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\03\03@072413 by brah

flavicon
face
part 0 44 bytes
his is a multi-part message in MIME format.
part 1 553 bytes content-type:text/plain; charset=us-ascii (decoded 7bit)



"Haris I. Volos" wrote:
>
> Hi!
>
> I am a beginner in PIC and I have built a specific circuit that features a
> 16x2 LCD which is connected to a 16F877 pic running at 4MHz.

Did some work on that a while back, and have been using the code, but
haven't looked at it for a while, so it's a bit unfamiliar.
However, the 2 attachments lm0321.asm I got from somewhere. lcd.asm is
my version of it.  It does work.

check your ports for data and commands and change if necessary

regards  Howard.

part 2 20300 bytes content-type:text/plain; charset=us-ascii;
(decoded 7bit)

       LIST P=16C64
       ERRORLEVEL  -302
;
; This program interfaces to a Hitachi (LM032L) 2 line by 20 character display
; module. The program assembles for either 4-bit or 8-bit data interface, depending
; on the value of the 4bit flag. LCD_DATA is the port which supplies the data to
; the LM032L, while LCD_CNTL is the port that has the control lines ( E, RS, RW ).
; In 4-bit mode the data is transfer on the high nibble of the port ( PORT<7:4> ).
;
;       Program = LM032L.ASM
;       Revision Date:   5-10-94
;                        1-22-97    Compatibility with MPASMWIN 1.40
;
;
      include <p16c64.inc>

ADCON1                  EQU             9F

FALSE                   EQU             0
TRUE                    EQU             1

      include <lm032l.h>
;
Four_bit         EQU     TRUE       ; Selects 4- or 8-bit data transfers
Data_HI          EQU     FALSE       ; If 4-bit transfers, Hi or Low nibble of PORT
;
;
   if ( Four_bit && !Data_HI )
;
LCD_DATA         EQU     PORTB
LCD_DATA_TRIS    EQU     TRISB
;
   else
;
LCD_DATA         EQU     PORTD
LCD_DATA_TRIS    EQU     TRISD
;
   endif
;
LCD_CNTL         EQU     PORTA
;
;
;
; LCD Display Commands and Control Signal names.
;
   if ( Four_bit && !Data_HI )
;
E                               EQU             0                               ; LCD Enable control line
RW                              EQU             1                               ; LCD Read/Write control line
RS                              EQU             2                               ; LCD Register Select control line
;
   else
;
E                               EQU             3                               ; LCD Enable control line
RW                              EQU             2                               ; LCD Read/Write control line
RS                              EQU             1                               ; LCD Register Select control line
;
   endif
;
;
TEMP1       EQU     0x030
;
      org     RESET_V                 ; RESET vector location
RESET       GOTO    START              ;
;
; This is the Periperal Interrupt routine. Should NOT get here
;
   page
       org     ISR_V              ; Interrupt vector location
PER_INT_V
ERROR1      BCF     STATUS, RP0         ; Bank 0
           BSF     PORTC, 0
           BCF     PORTC, 0
           GOTO    ERROR1
;
;
;
START                               ; POWER_ON Reset (Beginning of program)
           CLRF    STATUS          ; Do initialization (Bank 0)
           CLRF    INTCON
           CLRF    PIR1
           BSF     STATUS, RP0     ; Bank 1
           MOVLW   0x00            ; The LCD module does not like to work w/ weak pull-ups
           MOVWF   OPTION_REG        ;
           CLRF    PIE1            ; Disable all peripheral interrupts
           MOVLW   0xFF            ;
           MOVWF   ADCON1          ; Port A is Digital.
;
;
           BCF     STATUS, RP0     ; Bank 0
           CLRF    PORTA           ; ALL PORT output should output Low.
           CLRF    PORTB
           CLRF    PORTC
           CLRF    PORTD
           CLRF    PORTE
           BCF     T1CON, TMR1ON   ; Timer 1 is NOT incrementing
;
           BSF     STATUS, RP0     ; Select Bank 1
           CLRF    TRISA           ; RA5 -  0 outputs
           MOVLW   0xF0            ;
           MOVWF   TRISB           ; RB7 - 4 inputs, RB3 - 0 outputs
           CLRF    TRISC           ; RC Port are outputs
           BSF     TRISC, T1OSO    ; RC0 needs to be input for the oscillator to function
           CLRF    TRISD           ; RD Port are outputs
           CLRF    TRISE           ; RE Port are outputs
           BSF     PIE1, TMR1IE    ; Enable TMR1 Interrupt
           BSF     OPTION_REG,NOT_RBPU  ; Disable PORTB pull-ups
           BCF     STATUS, RP0     ; Select Bank 0
;
   page
;
; Initilize the LCD Display Module
;
           CLRF    LCD_CNTL        ; ALL PORT output should output Low.

DISPLAY_INIT
   if ( Four_bit && !Data_HI )
           MOVLW   0x02            ; Command for 4-bit interface low nibble
   endif
;
   if ( Four_bit && Data_HI )
           MOVLW   0x020           ; Command for 4-bit interface high nibble
   endif
;
   if ( !Four_bit )
           MOVLW   0x038           ; Command for 8-bit interface
   endif
;
           MOVWF   LCD_DATA        ;
           BSF     LCD_CNTL, E     ;
           BCF     LCD_CNTL, E     ;
;
; This routine takes the calculated times that the delay loop needs to
; be executed, based on the LCD_INIT_DELAY EQUate that includes the
; frequency of operation. These uses registers before they are needed to
; store the time.
;
LCD_DELAY   MOVLW   LCD_INIT_DELAY  ;
           MOVWF   MSD             ; Use MSD and LSD Registers to Initilize LCD
           CLRF    LSD             ;
LOOP2       DECFSZ  LSD, F          ; Delay time = MSD * ((3 * 256) + 3) * Tcy
           GOTO    LOOP2           ;
           DECFSZ  MSD, F          ;
END_LCD_DELAY
           GOTO    LOOP2           ;
;
; Command sequence for 2 lines of 5x7 characters
;
CMD_SEQ
;
   if ( Four_bit )
       if ( !Data_HI )
           MOVLW   0X02            ; 4-bit low nibble xfer
       else
           MOVLW   0X020           ; 4-bit high nibble xfer
       endif
;
   else                            ; 8-bit mode
           MOVLW   0X038
   endif
;
           MOVWF   LCD_DATA        ; This code for both 4-bit and 8-bit modes
           BSF     LCD_CNTL, E     ;
           BCF     LCD_CNTL, E     ;
;
   if ( Four_bit )                 ; This code for only 4-bit mode (2nd xfer)
       if ( !Data_HI )
           MOVLW   0x08            ; 4-bit low nibble xfer
       else
           MOVLW   0x080           ; 4-bit high nibble xfer
       endif
           MOVWF   LCD_DATA        ;
           BSF     LCD_CNTL, E     ;
           BCF     LCD_CNTL, E     ;
   endif
;
; Busy Flag should be valid after this point
;
           MOVLW   DISP_ON         ;
           CALL    SEND_CMD        ;
           MOVLW   CLR_DISP        ;
           CALL    SEND_CMD        ;
           MOVLW   ENTRY_INC       ;
           CALL    SEND_CMD        ;
           MOVLW   DD_RAM_ADDR     ;
           CALL    SEND_CMD        ;
;
   page
;
;Send a message the hard way
           movlw   'M'
           call    SEND_CHAR
           movlw   'i'
           call    SEND_CHAR
           movlw   'c'
           call    SEND_CHAR
           movlw   'r'
           call    SEND_CHAR
           movlw   'o'
           call    SEND_CHAR
           movlw   'c'
           call    SEND_CHAR
           movlw   'h'
           call    SEND_CHAR
           movlw   'i'
           call    SEND_CHAR
           movlw   'p'
           call    SEND_CHAR

           movlw   B'11000000'     ;Address DDRam first character, second line
           call    SEND_CMD

;Demonstration of the use of a table to output a message
           movlw   0               ;Table address of start of message
dispmsg
           movwf   TEMP1           ;TEMP1 holds start of message address
           call    Table
           andlw   0FFh            ;Check if at end of message (zero
           btfsc   STATUS,Z        ;returned at end)
           goto    out
           call    SEND_CHAR       ;Display character
           movf    TEMP1,w         ;Point to next character
           addlw   1
           goto    dispmsg
out
loop
           goto    loop            ;Stay here forever
;
;
INIT_DISPLAY
           MOVLW   DISP_ON             ; Display On, Cursor On
           CALL    SEND_CMD            ; Send This command to the Display Module
           MOVLW   CLR_DISP            ; Clear the Display
           CALL    SEND_CMD            ; Send This command to the Display Module
           MOVLW   ENTRY_INC           ; Set Entry Mode Inc., No shift
           CALL    SEND_CMD            ; Send This command to the Display Module
           RETURN
;
   page
;
;*******************************************************************
;* The LCD Module Subroutines                                      *
;*******************************************************************
;
   if ( Four_bit )      ; 4-bit Data transfers?
;
       if ( Data_HI )   ; 4-bit transfers on the high nibble of the PORT
;
;*******************************************************************
;*SendChar - Sends character to LCD                                *
;*This routine splits the character into the upper and lower       *
;*nibbles and sends them to the LCD, upper nibble first.           *
;*******************************************************************
;
SEND_CHAR
           MOVWF   CHAR            ;Character to be sent is in W
           CALL    BUSY_CHECK      ;Wait for LCD to be ready
           MOVF    CHAR, w
           ANDLW   0xF0            ;Get upper nibble
           MOVWF   LCD_DATA        ;Send data to LCD
           BCF     LCD_CNTL, RW   ;Set LCD to read
           BSF     LCD_CNTL, RS    ;Set LCD to data mode
           BSF     LCD_CNTL, E     ;toggle E for LCD
           BCF     LCD_CNTL, E
           SWAPF   CHAR, w
           ANDLW   0xF0            ;Get lower nibble
           MOVWF   LCD_DATA        ;Send data to LCD
           BSF     LCD_CNTL, E     ;toggle E for LCD
           BCF     LCD_CNTL, E
           RETURN
;
       else             ; 4-bit transfers on the low nibble of the PORT
;
;*******************************************************************
;* SEND_CHAR - Sends character to LCD                              *
;* This routine splits the character into the upper and lower      *
;* nibbles and sends them to the LCD, upper nibble first.          *
;* The data is transmitted on the PORT<3:0> pins                   *
;*******************************************************************
;
SEND_CHAR
           MOVWF   CHAR            ; Character to be sent is in W
           CALL    BUSY_CHECK      ; Wait for LCD to be ready
           SWAPF   CHAR, W
           ANDLW   0x0F            ; Get upper nibble
           MOVWF   LCD_DATA        ; Send data to LCD
           BCF     LCD_CNTL, RW   ; Set LCD to read
           BSF     LCD_CNTL, RS    ; Set LCD to data mode
           BSF     LCD_CNTL, E     ; toggle E for LCD
           BCF     LCD_CNTL, E
           MOVF    CHAR, W
           ANDLW   0x0F            ; Get lower nibble
           MOVWF   LCD_DATA        ; Send data to LCD
           BSF     LCD_CNTL, E     ; toggle E for LCD
           BCF     LCD_CNTL, E
           RETURN
;
       endif
   else
;
;*****************************************************************
;* SEND_CHAR - Sends character contained in register W to LCD    *
;* This routine sends the entire character to the PORT           *
;* The data is transmitted on the PORT<7:0> pins                 *
;*****************************************************************
;
SEND_CHAR
           MOVWF   CHAR            ; Character to be sent is in W
           CALL    BUSY_CHECK      ; Wait for LCD to be ready
           MOVF    CHAR, w
           MOVWF   LCD_DATA        ; Send data to LCD
           BCF     LCD_CNTL, RW   ; Set LCD in read mode
           BSF     LCD_CNTL, RS    ; Set LCD in data mode
           BSF     LCD_CNTL, E     ; toggle E for LCD
           BCF     LCD_CNTL, E
           RETURN
;
   endif
;
   page
;
;*******************************************************************
;* SendCmd - Sends command to LCD                                  *
;* This routine splits the command into the upper and lower        *
;* nibbles and sends them to the LCD, upper nibble first.          *
;* The data is transmitted on the PORT<3:0> pins                   *
;*******************************************************************
;
   if ( Four_bit )      ; 4-bit Data transfers?
;
       if ( Data_HI )   ; 4-bit transfers on the high nibble of the PORT
;
;*******************************************************************
;* SEND_CMD - Sends command to LCD                                 *
;* This routine splits the command into the upper and lower        *
;* nibbles and sends them to the LCD, upper nibble first.          *
;*******************************************************************

SEND_CMD
           MOVWF   CHAR            ; Character to be sent is in W
           CALL    BUSY_CHECK      ; Wait for LCD to be ready
           MOVF    CHAR,w
           ANDLW   0xF0            ; Get upper nibble
           MOVWF   LCD_DATA        ; Send data to LCD
           BCF     LCD_CNTL,RW    ; Set LCD to read
           BCF     LCD_CNTL,RS     ; Set LCD to command mode
           BSF     LCD_CNTL,E      ; toggle E for LCD
           BCF     LCD_CNTL,E
           SWAPF   CHAR,w
           ANDLW   0xF0            ; Get lower nibble
           MOVWF   LCD_DATA        ; Send data to LCD
           BSF     LCD_CNTL,E      ; toggle E for LCD
           BCF     LCD_CNTL,E
           RETURN
;
       else             ; 4-bit transfers on the low nibble of the PORT
;
SEND_CMD
           MOVWF   CHAR            ; Character to be sent is in W
           CALL    BUSY_CHECK      ; Wait for LCD to be ready
           SWAPF   CHAR, W
           ANDLW   0x0F            ; Get upper nibble
           MOVWF   LCD_DATA        ; Send data to LCD
           BCF     LCD_CNTL, RW   ; Set LCD to read
           BCF     LCD_CNTL, RS    ; Set LCD to command mode
           BSF     LCD_CNTL, E     ; toggle E for LCD
           BCF     LCD_CNTL, E
           MOVF    CHAR, W
           ANDLW   0x0F            ; Get lower nibble
           MOVWF   LCD_DATA        ; Send data to LCD
           BSF     LCD_CNTL, E     ; toggle E for LCD
           BCF     LCD_CNTL, E
           RETURN
;
       endif
   else
;
;**************************************************************
;* SEND_CND - Sends command contained in register W to LCD    *
;* This routine sends the entire character to the PORT        *
;* The data is transmitted on the PORT<7:0> pins              *
;**************************************************************

SEND_CMD
           MOVWF   CHAR            ; Command to be sent is in W
           CALL    BUSY_CHECK      ; Wait for LCD to be ready
           MOVF    CHAR, w
           MOVWF   LCD_DATA        ; Send data to LCD
           BCF     LCD_CNTL, RW   ; Set LCD in read mode
           BCF     LCD_CNTL, RS    ; Set LCD in command mode
           BSF     LCD_CNTL, E     ; toggle E for LCD
           BCF     LCD_CNTL, E
           RETURN
;
   endif
;
   page
;
   if ( Four_bit )      ; 4-bit Data transfers?
;
       if ( Data_HI )   ; 4-bit transfers on the high nibble of the PORT
;
;*******************************************************************
;* This routine checks the busy flag, returns when not busy        *
;*  Affects:                                                       *
;*      TEMP - Returned with busy/address                          *
;*******************************************************************
;
BUSY_CHECK
           BSF     STATUS, RP0     ; Select Register page 1
           MOVLW   0xFF            ; Set Port_D for input
           MOVWF   LCD_DATA_TRIS
           BCF     STATUS, RP0     ; Select Register page 0
           BCF     LCD_CNTL, RS    ; Set LCD for Command mode
           BSF     LCD_CNTL, RW   ; Setup to read busy flag
           BSF     LCD_CNTL, E     ; Set E high
           BCF     LCD_CNTL, E     ; Set E low
           MOVF    LCD_DATA, W     ; Read upper nibble busy flag, DDRam address
           ANDLW   0xF0            ; Mask out lower nibble
           MOVWF   TEMP
           BSF     LCD_CNTL, E     ; Toggle E to get lower nibble
           BCF     LCD_CNTL, E
           SWAPF   LCD_DATA, w     ; Read lower nibble busy flag, DDRam address
           ANDLW   0x0F            ; Mask out upper nibble
           IORWF   TEMP            ; Combine nibbles
           BTFSC   TEMP, 7         ; Check busy flag, high = busy
           GOTO    BUSY_CHECK      ; If busy, check again
           BCF     LCD_CNTL, RW
           BSF     STATUS, RP0     ; Select Register page 1
           MOVLW   0x0F
           MOVWF   LCD_DATA_TRIS   ; Set Port_D for output
           BCF     STATUS, RP0     ; Select Register page 0
           RETURN
;
       else             ; 4-bit transfers on the low nibble of the PORT
;
;*******************************************************************
;* This routine checks the busy flag, returns when not busy        *
;*  Affects:                                                       *
;*      TEMP - Returned with busy/address                          *
;*******************************************************************
;
BUSY_CHECK
           BSF     STATUS, RP0     ; Bank 1
           MOVLW   0xFF            ; Set PortB for input
           MOVWF   LCD_DATA_TRIS
           BCF     STATUS, RP0     ; Bank 0
           BCF     LCD_CNTL, RS    ; Set LCD for Command mode
           BSF     LCD_CNTL, RW   ; Setup to read busy flag
           BSF     LCD_CNTL, E     ; Set E high
           BCF     LCD_CNTL, E     ; Set E low
           SWAPF   LCD_DATA, W     ; Read upper nibble busy flag, DDRam address
           ANDLW   0xF0            ; Mask out lower nibble
           MOVWF   TEMP            ;
           BSF     LCD_CNTL, E     ; Toggle E to get lower nibble
           BCF     LCD_CNTL, E
           MOVF    LCD_DATA, W     ; Read lower nibble busy flag, DDRam address
           ANDLW   0x0F            ; Mask out upper nibble
           IORWF   TEMP, F         ; Combine nibbles
           BTFSC   TEMP, 7         ; Check busy flag, high = busy
           GOTO    BUSY_CHECK      ; If busy, check again
           BCF     LCD_CNTL, RW
           BSF     STATUS, RP0     ; Bank 1
           MOVLW   0xF0            ;
           MOVWF   LCD_DATA_TRIS   ; RB7 - 4 = inputs, RB3 - 0 = output
           BCF     STATUS, RP0     ; Bank 0
           RETURN
;
       endif
   else
;
;**************************************************************
;* This routine checks the busy flag, returns when not busy   *
;*  Affects:                                                  *
;*      TEMP - Returned with busy/address                     *
;**************************************************************
;
BUSY_CHECK
           BSF     STATUS,RP0      ; Select Register page 1
           MOVLW   0xFF            ; Set port_D for input
           MOVWF   LCD_DATA_TRIS
           BCF     STATUS, RP0     ; Select Register page 0
           BCF     LCD_CNTL, RS    ; Set LCD for command mode
           BSF     LCD_CNTL, RW   ; Setup to read busy flag
           BSF     LCD_CNTL, E     ; Set E high
           BCF     LCD_CNTL, E     ; Set E low
           MOVF    LCD_DATA, w     ; Read busy flag, DDram address
           MOVWF   TEMP
           BTFSC   TEMP, 7         ; Check busy flag, high=busy
           GOTO    BUSY_CHECK
           BCF     LCD_CNTL, RW
           BSF     STATUS, RP0     ; Select Register page 1
           MOVLW   0x00
           MOVWF   LCD_DATA_TRIS   ; Set port_D for output
           BCF     STATUS, RP0     ; Select Register page 0
           RETURN
;
   endif
   page
;
Table
           addwf   PCL, F          ;Jump to char pointed to in W reg
           retlw   'M'
           retlw   'i'
           retlw   'c'
           retlw   'r'
           retlw   'o'
           retlw   'c'
           retlw   'h'
           retlw   'i'
           retlw   'p'
           retlw   ' '
           retlw   'T'
           retlw   'e'
           retlw   'c'
           retlw   'h'
           retlw   'n'
           retlw   'o'
           retlw   'l'
           retlw   'o'
           retlw   'g'
           retlw   'y'
Table_End
           retlw   0
;
       if ( (Table & 0x0FF) >= (Table_End & 0x0FF) )
      MESSG   "Warning - User Definded: Table Table crosses page boundry in computed jump"
   endif
;



   end






part 3 7869 bytes content-type:text/plain; charset=us-ascii;
(decoded 7bit)

;definitions
       #define rs      porta,0 ;output to  lcd
       #define rw      porta,1 ;output to  lcd
       #define e       porta,2 ;output to  lcd
       #define lcd     portc   ;output to LCD
                               ;Data is lower nibble
       #define zflag   status,2        ;zero flag
       #define cflag   status,0        ;carry flag

;setup porta for digital
       movlw   b'00000110'     ;(adcon1 is in bank 1)
       movwf   adcon1  ;setup porta as digital on all pins (0 to 5)
;
;setup porta directions
       movlw   b'011000'       ;
       movwf   trisa
;setup portb
       clrf    portb
       movlw   b'11111111'     ;portb, hi nibble sec code. lwr nibble laser card buttons
       movwf   trisb


;setup portc
       clrf    portc
       movlw   b'11000000'     ;portc
       movwf   trisc

       ;bits 6,7 must both be inputs for usart

;************** WATCH *******************
;in busy_check, trisc is changed. be sure change doesn't affect bits 6 7
;****************************************

;rest of setup
============================================================
call    initlcd         ;initilises lcd - has to be run once

============================================================
;to send a command - load "char" with the command - call lcd_cmd

;to send a character (letter) - load "char" with the character (eltter)
;and call lcd_char


;============================================================
initlcd
;============================================================
       ;4 bits data is in lower nibble of lcd (portc)
;display control        0000 1 d c b
;d is 1=display on, 0=display off. c is 1=cursor on, 0=cursor off.
;b is 1 = blinking, 0 = not

;Entry Mode Set. 0000 0 1 i/d s
;i/d 1 = Address increments, 0 = decrements. s 1 = display shifts 0 = display does not shift
;(display shift is when the display scrolls left or right, depending on i/d)

;return home, clear display

;------------------
       bcf     e       ;e line lo
       bcf     rw      ;read/write line lo
       bcf     rs      ;rs line lo
;***
       movlw   b'00000011'     ;4 bit data flow command
       movwf   lcd     ;following sequence between ***'s
       bsf     e       ;has to be followed
       bcf     e       ;to initilise LCD to 4 bit mode
       call    tmr_125u
       call    tmr_5m  ;wait for more than 4.1 mS
       call    tmr_5m
       movlw   b'00000011'
       movwf   lcd
       bsf     e
       bcf     e
       call    tmr_125u        ;wait for 125 uS
       movlw   b'00000011'
       movwf   lcd
       bsf     e
       bcf     e
       call    tmr_125u        ;wait for 125 uS
       movlw   b'00000010'     ;note this is 00000010 not 00000011
       movwf   lcd
       bsf     e
       bcf     e       ;4 bits from here on
       call    tmr_125u
;***
       movlw   b'00101000'     ;4 bits 2 lines 5x8
       movwf   char
       call    lcd_cmd
;       movlw   b'00001111'     ;display on, cursor on, blinking on
;       movlw   b'00001110'     ;display on, cursor on, blinking off
       movlw   b'00001100'     ;display on, cursor off, blinking off
       movwf   char
       call    lcd_cmd
       movlw   b'00000001'     ;clear display
       movwf   char
       call    lcd_cmd
       movlw   b'00000110'     ;cursor move by inc. no display shift
       movwf   char    ;what's the fuck this mean?
       call    lcd_cmd
       call    tmr_5m  ;long delay to allow
       call    tmr_5m  ;lcd to settle itself
       call    tmr_5m
       call    tmr_5m
       return
;===============================================================================
;============================================================================
lcd_char        ;character to be sent is in char
;============================================================================
       call    busy_check      ; Wait for LCD to be ready
;send hi nibble first. port uses lo nibble as a sender
;have to keep hi nibble of portc unchanged when sending lo nibble to lcd
;character comes to here in char
       movfw   char
       movwf   temp
       swapf   temp,f  ;move hi nibble to lo nibble
       movfw   temp
       andlw   b'00001111'     ;make hi nibble all 0's, lo nibble is data
       movwf   temp
       movfw   lcd
       andlw   b'11110000'     ;make lo nibble all 0's, hi nibbel unchanged
       addwf   temp,w
       movwf   lcd
       BCF     RW      ; Set LCD to write
       BSF     RS      ; Set LCD to data mode
       BSF     E       ; toggle E for LCD
       BCF     E

       movfw   char
       movwf   temp
       andlw   b'00001111'     ;make hi nibble all 0's, lo nibble is data
       movwf   temp
       movfw   lcd
       andlw   b'11110000'     ;make lo nibble all 0's, hi nibbel unchanged
       addwf   temp,w
       movwf   lcd
       nop
       BSF     E       ; toggle E for LCD
       BCF     E
       RETURN
;============================================================
;=======================================================================
lcd_cmd ;character or command to be sent is in char
;=======================================================================
       call    busy_check      ; Wait for LCD to be ready
       movfw   char
       movwf   temp
       swapf   temp,f  ;move hi nibble to lo nibble
       movfw   temp
       andlw   b'00001111'     ;make hi nibble all 0's, lo nibble is data
       movwf   temp
       movfw   lcd
       andlw   b'11110000'     ;make lo nibble all 0's, hi nibbel unchanged
       addwf   temp,w
       movwf   lcd
       BCF     RW      ; Set LCD to write
       BCF     RS      ; Set LCD to data mode
       BSF     E       ; toggle E for LCD
       BCF     E

       movfw   char
       movwf   temp
       andlw   b'00001111'     ;make hi nibble all 0's, lo nibble is data
       movwf   temp
       movfw   lcd
       andlw   b'11110000'     ;make lo nibble all 0's, hi nibbel unchanged
       addwf   temp,w
       movwf   lcd
       nop
       BSF     E       ; toggle E for LCD
       BCF     E
       RETURN
;============================================================================
;===============================================================
busy_check
;===============================================================

;WATCH!!! upper four bits of trisc should be same as in setup
;only change lower four bits
       bsf     status, rp0     ; Bank 1
       movlw   b'11001111'     ;make lcd bits inputs
       movwf   trisc
       bcf     status, rp0 ; Bank 0

       bcf     rs      ; Set LCD for Command mode
       bsf     rw      ; Setup to read busy flag
check2  bsf     e       ; Set E high
       bcf     e       ; Set E low
       movfw   lcd     ;copy lcd to w
       andlw   b'00001111'     ;clear hi nibble (data is in lower nibble)
       movwf   temp    ;copy to temp
       swapf   temp,f  ;swap lo to hi (hi now has data)
       bsf     e       ;toggle
       bcf     e       ;toggle
       movfw   lcd     ;copy lcd tpo w
       andlw   b'00001111'     ;clear hi nibble (data is in lower nibble)
       addwf   temp,f  ;add w to existing temp, and call it temp
       btfsc   temp,7  ;skip if bit7 of temp is clear
                       ;which is the busy flag
       goto    check2  ;still busy
       bcf     rw      ;set lcd to write

       bsf     status, rp0 ;Bank 1
       movlw   b'11000000'
       movwf   trisc
       bcf     status, rp0 ; Bank 0

       nop     ;these nops are need
       nop     ;as LCD fucks about with addresses
       nop     ;for 4 uS after the busy flag drops
       nop
       nop
       return
;=======================================================================


part 4 154 bytes
--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2002\03\03@082130 by BENEDICIC SAMO

flavicon
face
Hi!

The best tutorial that I could find about LCD's is here:
http://www.epemag.com/frmlib.htm . It uses F84, but porting the code to 877
shouldn't be too big a problem. Regards, Samo

{Original Message removed}

2002\03\04@124641 by Haris I. Volos

flavicon
Thanks for the responce, by this time I have seen some responce from the LCD
but somewhere I miss something, so I would like to see your code to take
some ideas.

Haris
{Original Message removed}

2002\03\04@130859 by Nick Veys

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

Here you go.  Sorry if posting files on-list is bad everyone, but it's
only 4k. :)

It contains 16F870 code to get a HD44780 display initialized and
cleared.

And looking back at it (somewhat old), my macros are ugly, but the code
works and it'd be easy to adapt. :)

KILLspamnickKILLspamspamveys.com | http://www.veys.com/nick

> {Original Message removed}
part 2 6788 bytes content-type:application/octet-stream; (decode)

part 3 144 bytes
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


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