1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

LCD - Custom Character Display

Discussion in 'Assembly Language Programming (ALP) Forum' started by thebatosai, May 3, 2009.

  1. thebatosai

    thebatosai New Member

    Joined:
    May 3, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     
    Last edited by a moderator: May 4, 2009
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     
  3. thebatosai

    thebatosai New Member

    Joined:
    May 3, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     

    Attached Files:

  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    > 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?
     
  5. thebatosai

    thebatosai New Member

    Joined:
    May 3, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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.
     

Share This Page