Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   LCD - Custom Character Display (http://www.go4expert.com/forums/lcd-custom-character-display-t17302/)

thebatosai 4May2009 00:07

LCD - Custom Character Display
 
Hi,

I am trying to write a program to display custom character on LCD using CGRAM. I am using 68HC11 MCU and 20x2 LCD for this purpose.

I attached my code in attachment. I don't seem to get anything on LCD. The HEX pattern, CC, is supposed to look like a speaker. Any help would great.

Code:

ORG $6000

CC        FCB        $06,$0f,$0f,$0f,$0f,$0f,$0f,$00

 ORG $7000

MAIN                JSR LCD_CLR
                JSR DSP_CC
                SWI

DSP_CC                LDY #$40
                JSR LCD_TEST
                LDX #CC
                JSR LCD_DSP
                RTS

LCD_CLR        LDAA #$01
                JSR LCD_TEST
                      STAA $1400
                RTS

LCD_TEST        TST $1400
                    BMI LCD_TEST
                RTS
                               
LCD_DSP                LDAA 0,X
                LDAB 0,Y
                STAB $1400
                CMPA #00
                BEQ FINISH
                JSR LCD_TEST
                STAA $1401
                INX
                INY
                JMP LCD_DSP
FINISH                RTS


xpi0t0s 4May2009 15:26

Re: LCD - Custom Character Display
 
How does
Code:

00000110
00001111
00001111
00001111
00001111
00001111
00001111

look like a speaker?

How does the MCU know to start executing the program at $7000? I'm not a 68HC11 expert but I've done a bit of PIC programming and you need to put a jump at the start of program memory if that's not where the start of the program is. Obviously ignore this if the 68HC11 starts at $7000.

LDAA 0,X - OK, I guess this reads the 06 ff ff etc since X is initialised to #CC.
LDAB 0,Y - So what does this do? Y is initialised to #$40.

thebatosai 5May2009 00:47

Re: LCD - Custom Character Display
 
1 Attachment(s)
I am sorry that is definitely not speaker look alike. It is supposed to look like a battery. But the my it doesn't make difference to the problem.

Answering your question one at a time.

Once the program is loaded. Using a BUFFALO monitor program I would type go 7000 to run the program, Where 7000 is a hex and address from where my main subroutine starts.

Your second question, LDAB #$40, is the instruction that will initialize CGRAM. $40 corresponds to first row of 5x8 pixel map. So, $40~$47 for 8 rows. Last row is 00 for cursor.

I am newbie but I have some assembly and now trying to play around. I tried following the instruction in the website below but its for different MCU.

w w w.8051projects.net/lcd-interfacing/lcd-custom-character.php

xpi0t0s 5May2009 03:38

Re: LCD - Custom Character Display
 
> Your second question, LDAB #$40, is the instruction that will initialize CGRAM. $40 corresponds to first row of 5x8 pixel map. So, $40~$47 for 8 rows. Last row is 00 for cursor.

Um, sorry I'm being thick. Where's the instruction that writes to $40~47?

thebatosai 5May2009 06:47

Re: LCD - Custom Character Display
 
Hmm its alright. You see first Index Register Y is initialized to $40. Then it is incremented using INY. It is also stored in $1400 LCD Control Register, which tells the address in CGRAM to right hex pattern.


All times are GMT +5.5. The time now is 19:45.