Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

can someone help me to check the code of my LCD 4 bit config

Status
Not open for further replies.

McMurry

Member level 3
Joined
Feb 16, 2008
Messages
56
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,746
; i have set RB7:RB4 for D7:D4
and RS RB1
RW RB2
EN RB3
using general PIC.
;but it just come out as 2 rows of black blocks
;jhd162a is the lcd module i am using.
;i have read some tutorials on 4 bit config, that it unfortunately makes me confused a lot. can someone point out any of my mistake? thanks.

; all the what pin EQU pin no goes here...

ORG 0x00

BSF STATUS,RP0
CLRF TRISB
CLRF TRISA
BCF STATUS,RP0

CALL DELAY


;send init value 0x38
MOVLW 0x38
BCF PORTB, RS
BCF PORTB, RW
MOVWF PORTB
BCF PORTB, EN
CALL DELAY

;send init value 0x38
MOVLW 0x38
BCF PORTB, RS
BCF PORTB, RW
MOVWF PORTB
BCF PORTB, EN
CALL DELAY

;send init value 0x38
MOVLW 0x38
BCF PORTB, RS
BCF PORTB, RW
MOVWF PORTB
BCF PORTB, EN
CALL DELAY

;send init value 0x28
MOVLW 0x28
BCF PORTB, RS
BCF PORTB, RW
MOVWF PORTB
BCF PORTB, EN
CALL DELAY



MOVLW 0x43
MOVWF TEMP
MOVF TEMP, 0
SWAPF W, 0
ANDLW 0xF0
BSF PORTB, EN
BCF PORTB, RW
BCF PORTB, EN
MOVWF PORTB
BCF PORTB, EN
MOVF TEMP, 0
ANDLW 0xF0
BSF PORTB, EN
BCF PORTB, RW
BCF PORTB, RS
MOVWF PORTB
BCF PORTB, EN

CALL DELAY

LOOP GOTO LOOP

DELAY MOVLW D'255'
MOVWF D1 ;D1=4 for 1ms
COUNT MOVLW D'255'
MOVWF D2
COUNT1 DECFSZ D2, 1
GOTO COUNT1
DECFSZ D1, 1
GOTO COUNT
RETURN

END
 

Re: can someone help me to check the code of my LCD 4 bit co

;but it just come out as 2 rows of black blocks

It seems you have problem with contrast.

check it out first

Nandhu
 

    McMurry

    Points: 2
    Helpful Answer Positive Rating
Re: can someone help me to check the code of my LCD 4 bit co

hi nandhu,

thanks but the i've connected the Vee to ground through a 1k ohm resistor.
Should be no problem?

at least the lcd should display the character with hex code 43h?
 

You typically can't just tie a resistor between Vee & GND.

Use a 10K pot between +5 & GND with Vee on the wiper.
 

    McMurry

    Points: 2
    Helpful Answer Positive Rating
Re: can someone help me to check the code of my LCD 4 bit co

Hi,

Please note the following:

1. When LED is inited for four bit interfacing, you have to give the commands also as nibbles only.

2. The enable pin has to be toggled even for commands loading.

3. First load the data nibble and then set RS, R/W and finally toggle the EN bit to ensure that the RS and R/W bits which will change during data loading to port are set up to reqired states before toggling EN pin.

4. As per the data sheet I have, the first three data nibbles are 0X02 mostly being the MS nibble of 0x28 the function set command and during this period, the interface works in 8bit mode and LS nibbles are then don't care bits.

5. Next you have to give 0x28 as two nibbles followed by commands for Display ON/OFF, Entry Mode Set and Clear Display and command bytes as two nibbles only.

6. Only after the above sequence, you can send the data byte, again as two nibbles, but setting RS=1.

Please see your user manual once again and correct for above. You can make two subroutines, one each to Write Command and Write Data ,and call them each time after the CMD/Data byte loaded into W register.

Regards,
Laktronics
 

    McMurry

    Points: 2
    Helpful Answer Positive Rating
Hi laktronics, thanks. I finally make it work.
Also thanks nandhu and blueroom, cause thankfully i realises there are actually text appear on the LCD (i can see it at certain angle :p) but only covered by the dark boxes.

instead of putting a pot (cause i dont have one), i just put another resistor of kiloohm value. =)
 

Re: can someone help me to check the code of my LCD 4 bit co

Hi,

Please allow me to ask some question in this topic. May i know for LCD 4bit configuration. Is it possible for us to check the busy flag? for 8bit configure, we just have to check the last bit 0x80.

How can we check LCD busy for 4bit configuration?

Thank you.
 

Re: can someone help me to check the code of my LCD 4 bit co

Hi,
You can read the busy flag the same way, but you need to read and reject the second nibble containing address in this case.
Regards,
Laktronics
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top