Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Plesse check on my LCD Program

clranclran Member Posts: 20
Dear all,

I had wrote an intialization program for 4*20 character LCD module as shown below. I'm using m68HC11 microcontroller to interface the LCD. However, when i run the program, the LCD have no response to it? Why? Please help!




STACK EQU $DFFF
PIOC EQU $1002
DDRC EQU $1007
PORTC EQU $1003
PORTCL EQU $1005
IOPAT EQU $FF
PORTB EQU $1004
OPTION EQU $1039

RS EQU $01
RW EQU $02
ENABLE EQU $04
BUSYBIT EQU $80 ; BIT DB7

ORG $0010
PRINT_TABLE FCC 'HELLO JACKIE'
FCB $00



ORG $C000
LDS #STACK
LDAA #IOPAT
STAA DDRC
CLR PORTB
CLR PORTC


JSR CLEAR_DISPLAY
JSR RETURN_CURSOR
JSR SET_FUNCTION
JSR DISPLAY_ON
JSR ENTER_MODE


LDX #PRINT_TABLE
NEXT_MSG LDAA 0,X
BEQ MSG_END
JSR LCD_WRITE
INX
JMP NEXT_MSG

MSG_END SWI
STOP



FIRST_RESET LDAA #$30 ; SOFTWARE INITIALIZATION - NOT MANDATORY
JSR LCD_COMMAND ; WHEN INTERNAL POWER SUPPLY RESET CANNOT BE MET
JSR DELAY5MS ; THEN THE DISPALY MUST BE INITIALIZED BY
RTS ; THIS PROCEDURE

SECOND_RESET LDAA #$30
JSR LCD_COMMAND
JSR DELAY5MS
RTS

THIRD_RESET LDAA #$30
JSR LCD_COMMAND
JSR DELAY5MS
RTS

CLEAR_DISPLAY LDAA #$01 ; COMMAND CODE FOR CLEAR DISPLAY
JSR LCD_COMMAND ; SENT COMMAND
JSR DELAY5MS ; DELAY TIME FOR COMMAND
RTS

RETURN_CURSOR LDAA #$02 ; COMMAND CODE FOR RETURN CURSOR HOME
JSR LCD_COMMAND ; SENT COMMAND
JSR DELAY5MS ; DELAY TIME FOR COMMAND
RTS

SET_FUNCTION LDAA #$38 ; DL=1(8BIT), N=1(2LINE), F=0(5X8DOTS)
JSR LCD_COMMAND ; SENT COMMAND
JSR DELAY120US ; DELAY TIME FOR COMMAND
RTS

DISPLAY_ON LDAA #$0F ; D=1(DISPON),C=1(CURSORON),B=1(BLINKON)
JSR LCD_COMMAND ; SENT COMMAND
JSR DELAY120US ; DELAY TIME FOR COMMAND
RTS

ENTER_MODE LDAA #$06 ; I/D=1(INCREMENT),SH=0(NO SHIFT)
JSR LCD_COMMAND ; SENT COMMAND
JSR DELAY120US ; DELAY TIME FOR COMMAND
RTS



LCD_COMMAND STAA PORTC ; SENT COMMAND TO LCD
LDY #PORTB ; CONTROL PORTB
BCLR 0,Y,RW ; R/W=0 FOR WRITE
BCLR 0,Y,RS ; RS=0 (FOR COMMAND RS=0)
BSET 0,Y,ENABLE ; E=1, STROBE E HIGH
BCLR 0,Y,ENABLE ; E=0
RTS


LCD_WRITE JSR CHECK_BF
STAA PORTC ; SENT DATA TO LCD
LDY #PORTB
BCLR 0,Y,RW ; R/W=0 FOR WRITE
BSET 0,Y,RS ; RS=1 (FOR DATA RS=1)
BSET 0,Y,ENABLE ; E=1
BCLR 0,Y,ENABLE ; E=0
BCLR 0,Y,RS ; RS=0
JSR DELAY120US
RTS


DELAY120US LDY #34
AGAIN120US DEY
BNE AGAIN120US
RTS

DELAY5MS LDY #1428
AGAIN5MS DEY
BNE AGAIN5MS
RTS




Sign In or Register to comment.