
This project implements a segment LCD driver using four of Tiny Tapeout's IO pins as common pin drivers, and the remaining output-capable pins as segment drivers. It drives the COM pins high, low, and high impedance at a 1/4 duty cycle. When wired to an appropriate resistor network (see below), this gives COM voltages of 0V, VDD and VDD/2. It drives segment lines at either VDD or 0V. When a segment is driven in phase with its COM pin, it is not energized. When it is driven out of phase, it turns dark.
The chip can drive up to 48 segments (4×12), and you can write to the framebuffer by shifting bits in using an SPI-style interface (Mode 0). Note that with a slow system clock of 32.768 kHz, the SPI clock should be something like 8 kHz, which is quite slow. If you try even a modest SPI clock speed like 100 kHz, it will not work.
In my defense this was a learning project for me, my first project in Verilog and something I did to teach myself the concepts. I wanted to keep it as simple as possible in the hopes of getting something that works.
| Function | Signal | Tiny Tapeout pin | Direction |
|---|---|---|---|
| SPI | SCK | ui[0] |
input |
| SPI | MOSI | ui[1] |
input |
| SPI | CS_N | ui[2] |
input, active low |
| Common | COM0-COM3 | uio[0]-uio[3] |
output or hi-Z |
| Segment | SEG0-SEG7 | uo[0]-uo[7] |
output |
| Segment | SEG8-SEG11 | uio[4]-uio[7] |
output |
| Clock | System clock | clk |
clock input |
| Reset | Chip reset | rst_n |
input, active low |
This project requires a raw LCD glass with four common pins and up to 12 segment pins. You can source appropriate displays from Aliexpress. It also requires eight external resistors arranged as voltage dividers on the four COM lines. I haven't tested values yet but I sense that 100 kΩ is a reasonable starting point.
All eight resistors must have the same value.
VDD
│
┌─────┬──┴──┬─────┐
┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐
│R│ │R│ │R│ │R│
└┬┘ └┬┘ └┬┘ └┬┘
┌──────────────────┐ │ │ │ │ ┌────────────┐
│ uio[0] COM0 ├──●─────┼─────┼─────┼──┤ COM0 │
│ uio[1] COM1 ├──┼─────●─────┼─────┼──┤ COM1 │
│ uio[2] COM2 ├──┼─────┼─────●─────┼──┤ COM2 │
│ uio[3] COM3 ├──┼─────┼─────┼─────●──┤ COM3 │
│ │ │ │ │ │ │ │
│ │ ┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐ │ │
│ TT LCD driver │ │R│ │R│ │R│ │R│ │ LCD glass │
│ │ └┬┘ └┬┘ └┬┘ └┬┘ │ │
│ │ └─────┴──┬──┴─────┘ │ │
│ │ │ │ │
│ │ GND │ │
│ │ │ │
│ uo[7:0] SEG0–7 ╞═══════ 8 lines ═══════╡ SEG0–SEG7 │
│ uio[7:4] SEG8–11 ╞═══════ 4 lines ═══════╡ SEG8–SEG11 │
└──────────────────┘ └────────────┘
● = connected ┼ = crossing, not connected
Wire the COM pins to the voltage dividers as shown below. Wire the COM and SEG pins to your LCD glass. Set the clock to 32768 Hz, pulse the Reset pin, drive CS_N low, and then write six bytes of 0xFF to the LCD driver via its SPI pins. When you release CS_N, you should expect to see all segments energized. Then drive CS_N low, write six bytes of 0x00 and release it. All segments should go blank.
The segment mapping: COMn, SEGm is represented by bit n * 12 + m, sent most significant bit first. The first bit you send will be (3, 11) and the last bit (0, 0). The driver expects all 48 bits; there is no partial update. To avoid corrupting the framebuffer, any transaction with more or fewer than 48 bits will not trigger an update.
Note that sustained DC bias damages LCD glass over time. While the driver is running, it's ensuring that there is no DC bias reaching the segments, but when held in reset or when the clock is stopped, a DC bias may exist. Don't hold the chip in this state for a long time, or you risk damaging your LCD.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | SCK | SEG0 | COM0 |
| 1 | MOSI | SEG1 | COM1 |
| 2 | CS_N | SEG2 | COM2 |
| 3 | SEG3 | COM3 | |
| 4 | SEG4 | SEG8 | |
| 5 | SEG5 | SEG9 | |
| 6 | SEG6 | SEG10 | |
| 7 | SEG7 | SEG11 |