• We recently switched our forum platform. If you experience any issues please email support@crystalfontz.com

HELP!! 16*2 LCD interface with HC11

tsl83

New member
I'm currently doing the Undergraduate Final Year Project and I'm adding an LCD to my developement board.

The development board that i designed is M68HC11A1 based.

The LCD model that I'm using is the POWERTIP PC1602H with KS0066 as the LCD driver.

I'm facing some problem on interfacing the LCD to the HC11 and also on programming the LCD.

The wiring connections that i made is as below:

lcd pin1 ---- gnd
lcd pin2 ---- vcc
lcd pin3 ---- variable resistor
lcd pin4(RS) ---- mcu PA6
lcd pin5(RW')---- mcu PA3
lcd pin6(EN) ---- mcu PA5
lcd pin7 ---- mcu PC0
lcd pin8 ---- mcu PC1
lcd pin9 ---- mcu PC2
lcd pin10 ---- mcu PC3
lcd pin11 ---- mcu PC4
lcd pin12 ---- mcu PC5
lcd pin13 ---- mcu PC6
lcd pin14 ---- mcu PC7
lcd pin15 ---- +5V
lcd pin16 ---- gnd

I would like to know if the connections i've made are correct especially for the LED Backlights. Should I make the connections like this instead?

lcd pin15 ---- +4.2V
lcd pin16 ---- -4.2V

However, if I am to make this connection, I would like to know how can I supply a negative power since the power supply that I used for all devices are +5V and Gnd only.


I have written an asm program for my LCD but it doesn't work! Can anyone help me to figure out what's wrong with this program?

*EQUATES
PORTA EQU $1000
PORTC EQU $1003
DDRC EQU $1007
STACK EQU $DFFF

*MAIN PROGRAM
ORG $C000
START LDX #STACK
JSR INIT
JSR CLEAR
LDAB #$47 ;WRITE CHAR 'G'
JSR WRITE
LDAB #$6F ;WRITE CHAR 'O'
JSR WRITE
LDAB #$6F ;WRITE CHAR 'O'
JSR WRITE
LDAB #$64 ;WRITE CHAR 'D'
JSR WRITE
LDAB #$20 ;WRITE 'SPACE'
JSR WRITE
LDAB #$4D ;WRITE CHAR 'M'
JSR WRITE
LDAB #$6F ;WRITE CHAR 'O'
JSR WRITE
LDAB #$72 ;WRITE CHAR 'R'
JSR WRITE
LDAB #$6E ;WRITE CHAR 'N'
JSR WRITE
LDAB #$69 ;WRITE CHAR 'I'
JSR WRITE
LDAB #$6E ;WRITE CHAR 'N'
JSR WRITE
LDAB #$67 ;WRITE CHAR 'G'
JSR WRITE
NOP
SWI
END

*INITIALIZE LCD

INIT LDAA #$00
STAA PORTC
STAA PORTA ;CLEAR PORTC & PORTA

*INITIALIZE FUNCTION SET
LDAA $#FF
STAA DDRC ;PORTC AS OUTPUT
LDAA #$20
STAA PORTA ;EN=1, RS=0
LDAA #$38
STAA PORTC
LDAA #00
STAA PORTA ;CLEAR EN
JSR WAIT

*INITIALIZE DISPLAY ON/OFF CONTROL
LDAA $#FF
STAA DDRC ;PORTC AS OUTPUT
LDAA #$20
STAA PORTA ;EN=1, RS=0
LDAA #$0E
STAA PORTC
LDAA #00
STAA PORTA ;CLEAR EN
JSR WAIT

*INITIALIZE ENTRY MODE SET
LDAA $#FF
STAA DDRC ;PORTC AS OUTPUT
LDAA #$20
STAA PORTA ;EN=1, RS=0
LDAA #$06
STAA PORTC
LDAA #00
STAA PORTA ;CLEAR EN
JSR WAIT
RTS

*CLEAR DISPLAY
CLEAR LDAA $#FF
STAA DDRC ;PORTC AS OUTPUT
LDAA #$20
STAA PORTA ;SET EN=1, RS=0
LDAA #$01
STAA PORTC
LDAA #00
STAA PORTA ;CLEAR EN
JSR WAIT
RTS

*DISPLAY ON LCD
WRITE PSHB
LDAA $#FF
STAA DDRC ;PORTC AS OUTPUT
LDAA #$60
STAA PORTA ;EN=1, RS=1, RW'=0
PULB
STAB PORTC
LDAA #$00
STAA PORTA ;CLEAR CONTROL PINS
JSR WAIT
RTS

*CHECK BUSY FLAG
WAIT LDAA #$28 ;EN=1, RS=0, RW'=1
STAA PORTA
LDAA #$00
STAA DDRC ;PORTC AS INPUT
LDAA PORTC ;READ PSDB
ANDA #$80 ;CHECK THE BUSY FLAG
CMPA #$80
BEQ WAIT ;LOOP IF FLAG IS SET, ELSE
LDAA #$00
STAA PORTA ;EN=0, RS=0, RW'=0
RTS

ORG $FFFE
FDB START
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
I do not see any instance of setting PORTA to outputs (DDRA), so maybe your control signals are not happening.

The backlight should be connected from +5v to ground through a resistor which drops 0.8 volts, so that 4.2 volts is across the LEDs.
 
Top