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

Controlling HD44780 with a MCU

cc-crazed

New member
I am in the process of designing an embedded system around the 68HC11 and decided to use the CFAH2004A-TMI-JP, controlled through 8 port pins. Are there any design requirements/hints I should know about? For example, would you suggest a latch on these lines?

Also, the MCU is being programmed in assembly, and I am not sure about getting the timing right(the 2MHz chip processes a command every 500ns, a little fast for the HD44780). Are there any resources availiable for this MCU/LCD combo in assembly? Everything I can find is in BASIC or C++. Thanks!
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
Here is some HC11 code:
Code:
LCDINIT LDX #REGBASE
        JSR WDOG
        JSR DELY10
        JSR DELY10
        BCLR PORTB,X LCD_RS+LCD_RD      ;SET UP TO WRITE COMMANDS
        LDAB #$38       ;MODE BYTE
        JSR DSPWRT      ;WRITE TO LCD
        JSR DELY10
        JSR DSPWRT      ;WRITE TO LCD
        JSR DELY01
        JSR DSPWRT      ;WRITE TO LCD
        LDY #LCDINI
LCDI3   LDAB 0,Y
        BEQ LCDI4
        JSR DSPCMD      ;SEND INIT COMMAND STRING
        INY
        BRA LCDI3
LCDI4   LDY #SMLP       ;SMALL P
        JSR LCDI6
        LDY #SMLC       ;SMALL C
        JSR LCDI6
        LDY #SMLEQ      ;SMALL =
        JSR LCDI6
        LDY #ININD      ;SMALL SPECK
        JSR LCDI6
        LDY #INIDG      ;LARGE DIAMOND
LCDI6   LDAB 0,Y
        JSR DSPCMD      ;SETUP FOR CGRAM WRITE
        LDAA #8
LCDI7   LDAB 1,Y
        JSR DSPCHR      ;WRITE CHAR BITMAP TO CGRAM
        INY
        DECA
        BNE LCDI7
        RTS

LCDINI  DB $38,8,1,6,12,0
SMLC    DB $58,0,0,0,0,$E,$10,$10,$E
SMLP    DB $60,0,0,0,0,$1C,$12,$1C,$10
SMLEQ   DB $68,0,0,$E,0,$E,0,0,0
ININD   DB $70,0,0,0,0,0,0,0,1
INIDG   DB $78,0,0,0,4,$E,$1F,$E,4

DISPLAY PSHX
        JSR WDOG
DISP0   LDAB 0,Y        ;GET NEXT BYTE OF STRING
        BNE DISP1       ;ZERO TERMINATED
        PULX
        RTS
DISP1   BMI DISP2       ;>= $80 IS COMMAND CODE
        CMPB #3
        BLO DISP2       ;< 3 IS COMMAND CODE
        JSR DSPCHR      ;ELSE IS CHARACTER
        BRA DISP3
DISP2   JSR DSPCMD      ;SEND COMMAND
DISP3   INY
        BRA DISP0       ;GET NEXT BYTE

LCDBZY  LDX #REGBASE
        CLR DDRC,X
        BCLR PORTB,X LCD_RS     ;SELECT = COMMAND
        NOP
        BSET PORTB,X LCD_RD     ;SET UP FOR READ
        NOP
        BSET PORTB,X LCD_E
        NOP
LCDB2   BRSET PORTC,X $80 LCDB2 ;WAIT FOR BUSY FLAG TO GO LOW
        NOP
        BCLR PORTB,X LCD_E+LCD_RD   ;SET UP FOR WRITE
        BSET DDRC,X $FF
        RTS

DSPCMD  JSR LCDBZY
        BRA DSPWRT
DSPCHR  JSR LCDBZY
        BSET PORTB,X LCD_RS     ;SELECT = DATA
DSPWRT  NOP
        STAB PORTC,X
        NOP
        BSET PORTB,X LCD_E
        NOP
        NOP
        BCLR PORTB,X LCD_E
        RTS
 

cc-crazed

New member
Thanks!

I'll dig through this today to see how much I can use.

EDIT: I went through that and it is excelent. Exactly what I need. I can use it with almost no modification (I don't think i'll be using the COP watchdog, for example)
 
Last edited:
Top