"One fought back!" - Bill Herd.
Considering how I bent the poor thing's legs, it surely must be in pain! But it's getting the job done right.
I've spent a ridiculous amount of time trying to make LCD work with VIA. The VIA is great, the problem is HD44780 being a total arse with its 4-bit mode timings and with the initialization sequence.
After going around in circles, probing my LCD for hours with a digital analyzer, and reflashing my EPROM like 300 times, I've finally made it work. Many examples on the internet send 8-bit initialization nibble before switching to 4-bit mode, I couldn't get it to work unless I changed all 4 writes to 4-bit init. It still doesn't work reliably - most of the time it doesn't init on power-on, requiring me to reset manually.
Logic analyzer was extremely helpful - It helped my find places where I accidentally left some VIA lines floating by setting them as input when they were supposed to output, and gave me a good vision of the "shape" of the signal as well as of all the timings.
Attachment:
lcd_via_timing.png [ 36.88 KiB | Viewed 103430 times ]
I wanted to have as little busy waiting as possible, so I actually implemented reading of busy flag via 4-bit line.
My LCD code is here (don't judge me to hard, I'm still very new to 6502 assembly):
https://github.com/and3rson/65ad02/blob ... /src/lcd.sIt still contains a lot of busywaits for timing, but at least I've gotten the thing to work, and it's really fast - redrawing the entire screen takes less than 100ms. I think it can be improved since all my CPU delays are heavily padded. It also includes some nice tty-like screen scrolling, terminal style.
My old VIA-less code for 8-bit LCD operation is here:
https://github.com/and3rson/65ad02/blob ... old/lcd2.s - but it doesn't work with clock speed >500 KHz.
As for now, my SBC is successfully running @ 4 MHz, LCD is working, interrupts are firing, and I still have two control lines & 9 I/O bits available in my VIA.
My next stop is bit-banging a PS/2 keyboard & interfacing with I2C devices.
<rant>
I wish PS/2 protocol had 8-bit packets! It could then work so nicely with 6522's shift register...
</rant>
I also managed to configure VIA to generate periodic interrupts - it's going to be very handy with playing .SID tracks from HVSC (
https://hvsc.c64.org/). I've did some basic testing and could hear a very faint sound coming from my speakers - I guess those capacitor values in C64 schematic are indeed very important! (I suck at analog circuits!)
Garth - your LCD ASM examples were very helpful!
Jeff - thanks for the tip, I've pulled the inputs up to be on the safe side!
_________________
/Andrew
deck65 - 6502 slab with screen and keyboard |
ПК-88 - SBC based on KM1810VM88 (Ukrainian i8088 clone) |
leo80 - simple Z80 SBC
nice65 - 6502 assembly linter |
My parts, footprints & 3D models for KiCad/FreeCAD