Well, I’ve been swimming along with my homebrew Z80 computer that I’ve been designing. But of course, there are always snags. In fact, there are a million snags usually per each success. This is, as many who delve into this kind of stuff know, the nature of the beast.
Today’s frustration/snag/snafu is one that is invoking a particular ire. Namely, my LCD will NOT initialize!
A little context…
The 1602 16×2 LCD screen is pretty well standard stock electronics device. There are variations out there but the command set to initialize the screen is the same. We need to initialize the screen to tell it how to function. This is done via the register select pin which needs to be held low which indicates the data on the data bus in an instruction. That’s all fine. When the register select is reverted to high the LCD then knows it’s receiving a data byte which will display a character. Got it. Cool.

What follows is a chart explaining the proper initialization technique—which I have followed and consciously, bit-by-bit broken down to assure I am in the right.

I realize also that the LCD screen is a little slow and likes delays between initialization commands so it can digest the info. Got it. Cool. The Z80 is currently running in the KHz with delays well-exceeding the requirements. We’re good there.
I have brought out the logic analyzer and even it shows a proper arrangement of bits which would indicate the display should be initializing. That follows here:

One will note that the logic analyzer proves that the timing is correct and the values match the code below. This all indicates an LCD that SHOULD BE initializing. For instance we can see that the LCD screen does in fact have RS low whereafter the first value of my assembly code is seen— the value $30 in hexadecimal or 00110000 in binary. The analyzer goes on to prove every value is right and the timing too.
; Pt3.1LCD.z80
; Constants
lcd_command equ $20 ; LCD command I/O port
lcd_data equ $30 ; LCD data I/O port
.org 0000h
ld a,$30 ; first instance function set:
out (lcd_command),a
ld a,$30 ; second instance function set
out (lcd_command),a
ld a,$30 ; third instance function set
out (lcd_command),a
ld a,$38 ; real function set instance; 8-bit interface, 2-line, small font
out (lcd_command),a
ld a,$0F ; Display on
out (lcd_command),a ;
ld a,$06 ; Entry mode: left to right, no shift
out (lcd_command),a
ld a,$01 ; Clear display
out (lcd_command),a
ld hl,message ; Message address
message_loop: ; Loop back here for next character
ld a,(hl) ; Load character into A
and a ; Test for end of string (A=0)
jr z,done
out (lcd_data),a ; Output the character
inc hl ; Point to next character (INC=increment, or add 1, to HL)
jr message_loop ; Loop back for next character
done:
Counter1 OUT (0x10),a
inc a
JP Counter1
JP 0000h
message:
db "Coleman Z80 ",0
Yet, for all this IT WILL NOT initialize lol. This video shows how the LCD is not initializing yet the Z80 is working properly as it carries on after the LCD code to run a generic counter on the output port 1, labeled accordingly.
I figure its prudent to log failures here as well. Because ultimately they turn into successes and I can look back and say with exasperation, “You blundering idiot! You forgot to <fill in the easy solution here>!”
In fact, I have seem some success. Mostly by physically messing with the wires and ‘force-initializing’ we’ll call it. When I mix up the E and RS pins while the processor is running the code, then RESET the computer after, the screen will initialize. I then place E and RS back in their normal positions and the LCD starts properly receiving character data. I am assuming this is because E is held low, which is now in the place of RS, which allows the LCD to see instruction code. Yet physically holding RS to low does not create the same success. Alas, one can see the cause for frustration!
However, all of that is pretty inspiring as to carrying on with this dilemma. I’m certain after a few more sleepless nights I’ll wake up with the answer.
Anyways, to prove I’ve seen some success, and to prove the system can, in fact work, here’s an image of a short message I sent for example.

We will prevail!
Leave a Reply