#include "c:\miniide\hcs12.inc" lcdPort equ PTH ; LCD data pins lcdDIR equ DDRH ; LCD data direction port lcdCtl equ PTK ; LCD control port lcdCtlDIR equ DDRK ; LCD control port direction lcdE equ $80 ; E signal pin (PK7) lcdRW equ $20 ; R/W signal pin (PK5) lcdRS equ $10 ; RS signal pin (PK4) ; ****************************************************************************** ; This function sends a command in accumulator A to the LCD. ; ****************************************************************************** cmd2lcd bclr lcdCtl,lcdRS+lcdRW ; select instruction register and Write bset lcdCtl,lcdE ; pull the E signal high staa lcdPort ; send the command, along with RS, E signals nop nop bclr lcdCtl,lcdE ; pull the E signal low bset lcdCtl,lcdRW ; pull R/W to high ldy #1 ; adding this delay will complete the internal jsr delayby50us ; operation for most instructions rts ; ****************************************************************************** ; The following function performs initialization to the LCD used in Dragon12 ; demo board with 8-bit data width, two-line display, turn on display, cursor, ; and blinking. Shift cursor right, clear display and return to home position. ; ****************************************************************************** openlcd movb #$FF,lcdDIR ; configure port H for output bset lcdCtlDir,$B0 ; configure control pins for output ldy #5 ; wait for LCD to complete internal jsr delayby100ms ; configuration ldaa #$38 ; set 8-bit data, 2-line display, 5x8 font jsr cmd2lcd ; " ldaa #$0F ; turn on display, cursor, and blinking jsr cmd2lcd ; " ldaa #$06 ; move cursor right (entry mode set instruction) jsr cmd2lcd ; " ldaa #$01 ; clear cursor and return to home position jsr cmd2lcd ; " ldy #2 ; wait until "clear display" command is complete jsr delayby1ms ; " rts ; ************************************************************************************* ; The following function outputs the character in accumulator in A to LCD. ; ************************************************************************************* putc2lcd bset lcdCtl,lcdRS ; select LCD Data register bclr lcdCtl,lcdRW ; enable write to LCD bset lcdCtl,lcdE ; pull E to high staa lcdPort ; send data to LCD nop ; provide enough length to E signal nop ; " bclr lcdCtl,lcdE ; pull the E signal low bset lcdCtl,lcdRW ; pull R/W high to complete the write cycle ldy #1 ; wait until the write operation is jsr delayby50us ; complete rts ; ************************************************************************************ ; The following function outputs a NULL-terminated string pointed to by X. ; ************************************************************************************ puts2lcd ldaa 1,x+ ; get one character from the string beq done_puts ; reach NULL character? jsr putc2lcd bra puts2lcd done_puts rts #include "c:\miniide\delay.asm" end