lcd display

Started by Lerzan Celikkanat February 25, 2005

Hi

I'm trying to develop this LCD display for a school project. I wrote a piece
of code for the LCD display but the LCD screen doesn't print anything.

Could someone tell me what is wrong with my code? (below)
PORTT EQU $0240
PORTM EQU $0250

DDRT EQU $0242
DDRM EQU $0252

ORG $100
; set port data patterns and directions
TRYLCD LDAA #$FF
STAA DDRM
STAA DDRT
LDAA #$E8
STAA DDRM

; LCD display peripheral needs to be initilized
LDAA #$01
JSR WCTRL ; clear
LDAA #$02
JSR WCTRL
LDAA #$38
JSR WCTRL
LDAA #$0C
JSR WCTRL
LDAA #$06
JSR WCTRL

HERE LDAA #!0 ; ascii a
DLP JSR WDAT ; display a character
INCA ; to next character
CMPA #!: ; ascii t
BNE DLP ; loop till t
BRA HERE ; Stop

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

WCTRL STAA PORTT
BSET PORTM,%00000010
BCLR PORTM,%00000010
RTS ;************************************************************** WDAT STAA PORTT
BSET PORTM,%00000001
BSET PORTM,%00000010
BCLR PORTM,%00000010
BCLR PORTM,%00000001
RTS



Re: lcd display
Re: lcd display

Not knowing the details of your display and hookup, it's hard to
criticize the details of your code. But one thing stands out...you
are writing to that poor LCD pretty darned fast. Most LCD's are
very, very slow devices that require delays of up to several
milliseconds between writes, and fairly wide strobes. Look carefully
at the specs in the data sheet, and then start adding appropriate
delays in your code.

If you're using a Real Time Interrupt, or you have some existing
periodic interrupt, that might be good place to handle your LCD
functions without tying up your CPU with long software delays. Just
implement a state machine that does a little bit of the work of
writing to the LCD on each interrupt.

Bill T.
http://www.kupercontrols.com --- In , "Lerzan Celikkanat" <lerzan83@h...>
wrote:
>
> Hi
>
> I'm trying to develop this LCD display for a school project. I
wrote a piece
> of code for the LCD display but the LCD screen doesn't print
anything.
>
> Could someone tell me what is wrong with my code? (below) >
> PORTT EQU $0240
> PORTM EQU $0250
>
> DDRT EQU $0242
> DDRM EQU $0252 >
>
> ORG $100
> ; set port data patterns and directions
> TRYLCD LDAA #$FF
> STAA DDRM
> STAA DDRT
> LDAA #$E8
> STAA DDRM
>
> ; LCD display peripheral needs to be initilized
> LDAA #$01
> JSR WCTRL ; clear
> LDAA #$02
> JSR WCTRL
> LDAA #$38
> JSR WCTRL
> LDAA #$0C
> JSR WCTRL
> LDAA #$06
> JSR WCTRL
>
> HERE LDAA #!0 ; ascii a
> DLP JSR WDAT ; display a character
> INCA ; to next character
> CMPA #!: ; ascii t
> BNE DLP ; loop till t
> BRA HERE ; Stop >
>
> ;*************************************************************
>
> WCTRL STAA PORTT
> BSET PORTM,%00000010
> BCLR PORTM,%00000010
> RTS > ;************************************************************** > WDAT STAA PORTT
> BSET PORTM,%00000001
> BSET PORTM,%00000010
> BCLR PORTM,%00000010
> BCLR PORTM,%00000001
> RTS





without looking through all the code, first I
would guess you are running too fast for the
LCD as there are no delays or checking of the
busy flag..

Darren Moore

> -----Original Message-----
> From: Lerzan Celikkanat [mailto:] > Hi
>
> I'm trying to develop this LCD display for a school project.
> I wrote a piece
> of code for the LCD display but the LCD screen doesn't print anything.
>
> Could someone tell me what is wrong with my code? (below) >
> PORTT EQU $0240
> PORTM EQU $0250
>
> DDRT EQU $0242
> DDRM EQU $0252 >
>
> ORG $100
> ; set port data patterns and directions
> TRYLCD LDAA #$FF
> STAA DDRM
> STAA DDRT
> LDAA #$E8
> STAA DDRM
>
> ; LCD display peripheral needs to be initilized
> LDAA #$01
> JSR WCTRL ; clear
> LDAA #$02
> JSR WCTRL
> LDAA #$38
> JSR WCTRL
> LDAA #$0C
> JSR WCTRL
> LDAA #$06
> JSR WCTRL
>
> HERE LDAA #!0 ; ascii a
> DLP JSR WDAT ; display a character
> INCA ; to next character
> CMPA #!: ; ascii t
> BNE DLP ; loop till t
> BRA HERE ; Stop >
>
> ;*************************************************************
>
> WCTRL STAA PORTT
> BSET PORTM,%00000010
> BCLR PORTM,%00000010
> RTS > ;************************************************************** > WDAT STAA PORTT
> BSET PORTM,%00000001
> BSET PORTM,%00000010
> BCLR PORTM,%00000010
> BCLR PORTM,%00000001
> RTS > Yahoo! Groups Links




Hi

From your code it looks like your LCD module is HD44780 compatible. Check
following application note:

http://www.freescale.com/files/microcontrollers/doc/app_note/AN1774.pdf

Edward
----- Original Message -----
From: "Lerzan Celikkanat" <>
To: <>
Sent: Friday, February 25, 2005 7:26 AM
Subject: [68HC12] lcd display >
>
> Hi
>
> I'm trying to develop this LCD display for a school project. I wrote a
> piece
> of code for the LCD display but the LCD screen doesn't print anything.
>
> Could someone tell me what is wrong with my code? (below) >
> PORTT EQU $0240
> PORTM EQU $0250
>
> DDRT EQU $0242
> DDRM EQU $0252 >
>
> ORG $100
> ; set port data patterns and directions
> TRYLCD LDAA #$FF
> STAA DDRM
> STAA DDRT
> LDAA #$E8
> STAA DDRM
>
> ; LCD display peripheral needs to be initilized
> LDAA #$01
> JSR WCTRL ; clear
> LDAA #$02
> JSR WCTRL
> LDAA #$38
> JSR WCTRL
> LDAA #$0C
> JSR WCTRL
> LDAA #$06
> JSR WCTRL
>
> HERE LDAA #!0 ; ascii a
> DLP JSR WDAT ; display a character
> INCA ; to next character
> CMPA #!: ; ascii t
> BNE DLP ; loop till t
> BRA HERE ; Stop >
>
> ;*************************************************************
>
> WCTRL STAA PORTT
> BSET PORTM,%00000010
> BCLR PORTM,%00000010
> RTS > ;************************************************************** > WDAT STAA PORTT
> BSET PORTM,%00000001
> BSET PORTM,%00000010
> BCLR PORTM,%00000010
> BCLR PORTM,%00000001
> RTS > Yahoo! Groups Links >
>


>
> Hi
>
> I'm trying to develop this LCD display for a school project. I wrote a piece
> of code for the LCD display but the LCD screen doesn't print anything.
>
> Could someone tell me what is wrong with my code? (below) >

Hello,

Besides what others have said about speed, You may also have to put a negative
voltage on the contrast pin in order to see anyting on the display. If you can
turn the contrast so high that You can see the blank characters You probably
are OK. If not, you may need a negative voltage. Otherwise the characters may
be there but You just can't see them. For testing, You can use a battery and a
potentiometer. I have used one output pin, one small capacitor, two diodes, one
(contrast-) potentiometer and one large capacitor produce the negative voltage
that was needed.

You should be able to tell if You have a speed problem if You single step
through the code - that should put enough delays between operations. I always
use a buffer and the busy function as part of a state machine too print to the
display. This costs one more pin (read/write) but in my opinion it is worth it.
It also enables You to use the display as an offchip ram (probably not needed
on a HCS12 though).

Regards / Ruben

==============================
Ruben Jsson
AB Liros Electronic
Box 9124, 200 39 Malm Sweden
TEL INT +46 40142078
FAX INT +46 40947388

==============================