Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

lcd : cursor address location unknown.. :(

Status
Not open for further replies.

bouvett

New Member
hi,

i bought a 2* 8 character lcd same exactly as this

**broken link removed**

unfortunately no detail is given on the cursor address location of the lcd (i never used an 8*2 lcd before)... the first location in the first row can be accessed either by 80 or by 00, the problem is when i have to access the second row...
any help is greatly appreciated..
thanks.. regards:)
 
hi,

i bought a 2* 8 character lcd same exactly as this

**broken link removed**

unfortunately no detail is given on the cursor address location of the lcd (i never used an 8*2 lcd before)... the first location in the first row can be accessed either by 80 or by 00, the problem is when i have to access the second row...
any help is greatly appreciated..
thanks.. regards:)

hi,
The 2nd row is 40 or 0xc0.

EDIT:
this is the KS0006 controller for your LCD.
 

Attachments

  • KS0066.pdf
    528.3 KB · Views: 337
Last edited:
i tried that but it doesn't work

this is my code:

;Microcontroller : PIC16F54
;This code performs a series of led tricks using 11 outputs and a ingle input
;The input will change the the mode selection
;Designed for an oscillator of 4Mhz
;Input is momentarily high

;EQU SECTION
;******************************************************************************

TMR0 EQU 1H
PCL EQU 2H
STATUS EQU 3H
FSR EQU 4H
PORTA EQU 5H
PORTB EQU 6H
COUNTER EQU 7H ; USED AS A GENERAL PURPOSE COUNTER
CARRY_BIT EQU 0
ZERO_BIT EQU 2
TIME EQU 8H ;USED FOR SUBTARCTION IN THE DELAY

;******************************************************************************

LIST P=16F54

ORG 1FFH
GOTO INITIAL_SETTINGS ;AT RESET START SETTINGS

ORG 0 ;START CODE

;******************************************************************************


;SUBROUTINE SECTION
;******************************************************************************

DELAY1 CLRF TMR0 ;CLEAR TIMER
MOVLW .1 ;150 COUNTS REPRESENT 0.065 SECONDS
MOVWF COUNTER

LOOP1 MOVF TMR0,W ;CHECK TIMER
SUBWF TIME,0

BTFSS STATUS,ZERO_BIT ;IF TIMER IS 255, TIME ELAPSED
GOTO LOOP1 ;NO
DECFSZ COUNTER ;YES, CHECK WHETHER TOTAL TIME ELAPSED
GOTO LOOP1 ;NO
BCF STATUS,CARRY_BIT ;SET CARRY BIT TO 0
RETLW 0 ;YES, THEREFORE RETURN

DELAY2 CLRF TMR0 ;CLEAR TIMER
MOVLW .200 ;150 COUNTS REPRESENT 0.065 SECONDS
MOVWF COUNTER

LOOP2 MOVF TMR0,W ;CHECK TIMER
SUBWF TIME,0

BTFSS STATUS,ZERO_BIT ;IF TIMER IS 255, TIME ELAPSED
GOTO LOOP1 ;NO
DECFSZ COUNTER ;YES, CHECK WHETHER TOTAL TIME ELAPSED
GOTO LOOP1 ;NO
BCF STATUS,CARRY_BIT ;SET CARRY BIT TO 0
RETLW 0 ;YES, THEREFORE RETURN

CLOCK BSF PORTA,2
NOP
NOP
NOP
BCF PORTA,2
NOP
NOP
NOP
RETLW 0

;FOLLOWING FUNCTIONS USED TO DISPLAY CHARACTERS
A MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVLW 1H ;41 is code for A
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

BB MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVLW 2H ;42 is code for B
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0


E MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVLW 5H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

I MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVLW 9H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0


L MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVLW 0CH
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

N MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
MOVLW 0EH
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0



S MOVLW 2
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVLW 3H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

T MOVLW 2
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVLW 4H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

H MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVLW 8H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

GAP MOVLW 2
MOVWF PORTA
MOVLW 2H
MOVWF PORTB
CALL CLOCK
MOVLW 0H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

LA MOVLW 2
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVLW 0CH
MOVWF PORTB
CALL CLOCK
RETLW 0

RA MOVLW 2
MOVWF PORTA
MOVLW 3H
MOVWF PORTB
CALL CLOCK
MOVLW 0EH
MOVWF PORTB
CALL CLOCK
RETLW 0

O MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVLW 0FH
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

P MOVLW 2
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVLW 0H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

WW MOVLW 2
MOVWF PORTA
MOVLW 5H
MOVWF PORTB
CALL CLOCK
MOVLW 7H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

D MOVLW 2 ;enables the display
MOVWF PORTA
MOVLW 4H
MOVWF PORTB
CALL CLOCK
MOVLW 4H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
RETLW 0

CLRDISP CLRF PORTA
MOVLW 0H
MOVWF PORTB
CALL CLOCK ;clock character onto display.
MOVLW 1
MOVWF PORTB
CALL CLOCK
CALL DELAY1
RETLW 0


;******************************************************************************

;CONFIGURATION BITS
;******************************************************************************

__CONFIG H'03FA' ;WATCHDOG TIMER OFF, CODE PROTECTION DISABLED, HS OSCILLATOR

;******************************************************************************

INITIAL_SETTINGS MOVLW B'00000000' ;ALL BITS OF PORTA ARE OUTPUTS EXCEPT THE BIT 0
TRIS PORTA

MOVLW B'00000000' ;ALL BITS OF PORTB ARE OUTPUTS
TRIS PORTB

MOVLW B'00000011'
OPTION

MOVLW .255 ; SET TIME VALUE, USED FOR THE DELAY
MOVWF TIME

CLRF PORTA
CLRF PORTB

;DISPLAY CONFIGURATION

MOVLW 03H ;FUNCTION SET
MOVWF PORTB ;8bit data (default)
CALL CLOCK

CALL DELAY1 ;wait for display

MOVLW 02H ;FUNCTION SET
MOVWF PORTB ;change to 4bit
CALL CLOCK ;clock in data

CALL DELAY1 ;wait for display
MOVLW 02H ;FUNCTION SET
MOVWF PORTB ;must repeat command
CALL CLOCK ;clock in data

CALL DELAY1 ;wait for display
MOVLW 08H ;4 bit micro
MOVWF PORTB ;using 2 line display.
CALL CLOCK ;clock in data

CALL DELAY1
MOVLW 0H ;Display on, cursor off
MOVWF PORTB ;0CH
CALL CLOCK
MOVLW 0CH
MOVWF PORTB
CALL CLOCK

CALL DELAY1
MOVLW 0H ;Increment cursor, 06H
MOVWF PORTB
CALL CLOCK
MOVLW 6H
MOVWF PORTB
CALL CLOCK

;******************************************************************************

;PROGRAM STARTS HERE

CALL DELAY2 ; DELAY NEEDE SO THAT THE MICROCONTROLLER AND THE LCD HAVE TIME TO SETTLE DOWN

BEGIN CALL CLRDISP
CLRF PORTA
MOVLW 8H ;Cursor at top left, 80H
MOVWF PORTB
CALL CLOCK
MOVLW 0H
MOVWF PORTB
CALL CLOCK

CALL DELAY1

CALL N ;display M
CALL DELAY2 ;wait 0.1 seconds
CALL A ;display I
CALL DELAY2 ;wait 0.1 seconds
CALL I ;Etc.
CALL DELAY2
CALL L
CALL DELAY2
CALL GAP
CALL DELAY2
CALL RA
CALL DELAY2
CALL A
CALL DELAY2
CALL L

LOOP CLRF PORTA ;COMMAND TYPE
MOVLW 0CH ;Cursor on second line, C3
MOVWF PORTB
CALL CLOCK
MOVLW 0H
MOVWF PORTB
CALL CLOCK

CALL DELAY1

CALL A
CALL DELAY1
CALL GAP
CALL DELAY1
CALL A
CALL DELAY1
hey goto hey
;******************************************************************************

END
 
i tried this by both 0xc0 and 40 but still the second row did not output anything.. note that the first row works well
 
i tried this by both 0xc0 and 40 but still the second row did not output anything.. note that the first row works well

hi,

Tried your code, where is the LCD RS control pin.???

That selects the LCD between commands and data.
 
heh glad to see you have it. But i also noticed in your code the original values you used are reversed. if you use 8H isnt that a 0x08? and not a 0x80. And

MOVLW 0CH ;Cursor on second line, C3

isnt it supposed to be 40H?

This is straight from datasheet:
Set DDRAM address to AC.
This instruction makes DDRAM data available from MPU.
When 1-line display mode (N = Low), DDRAM address is from “00H” to “4FH”.
In 2-line display mode (N = High), DDRAM address in the 1st line is from “00H” to “27H”, and DDRAM address
in the 2nd line is from “40H” to “67H”.
 
heh glad to see you have it. But i also noticed in your code the original values you used are reversed. if you use 8H isnt that a 0x08? and not a 0x80. And

MOVLW 0CH ;Cursor on second line, C3

isnt it supposed to be 40H?

This is straight from datasheet:

hi atom,
I am puzzled that the OP says the posted code works.:)

I tried quite a while yesterday to do a first aid job on the program trying to get anything out of it.?

Finally gave up, found so many errors and problems.

Hope the new job is going according to plan.;)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top