1.8-inch TFT/First light/06. Clock, data, DC and CS
First light · 06 of 10

Clock, data, DC and CS

SCL ticks once per bit and MOSI carries the bit. CS goes LOW to say this display is being spoken to. DC says whether each byte is a command or data: LOW for set a window or start writing, HIGH for the window's corners and the pixels. A wrong DC turns commands into colours, which is why a DC fault looks like garbage rather than nothing.

Four wires, one byte at a time

SPI is a clock and a data line. Your board drives SCL, and with every tick it puts one bit on MOSI; eight ticks are one byte. The display only listens. That is two wires. The other two are the display's own.

CS, chip select, goes LOW before the display is spoken to and HIGH after. A display whose CS is HIGH ignores the clock and the data, so other SPI parts can share SCL and MOSI, each with its own CS.

DC, data or command, is read with every byte. LOW means the byte is a command. HIGH means it is data for the last command. The ST7735S data sheet calls it D/CX.

One fill, down four wires
DC
-
CS
HIGH
Full frame
40,960 B
Press Send it to watch one fillScreen(RED) go down the wires: CS, DC, the clock and the data, one step at a time.

What fillScreen sends

Drawing anything is three commands. CASET (2Ah) sets the first and last column of a window. RASET (2Bh) sets its first and last row. RAMWR (2Ch) says the pixels come next, and every byte after it, with DC HIGH, goes into the window left to right and top to bottom, two bytes a pixel. Red is F800 in the 16-bit colour the library sends, called RGB565: 5 bits of red, 6 of green, 5 of blue.

A small window is a few bytes of setup and a few hundred of pixels. The whole screen is the same setup and 40,960 bytes of pixels. That difference is the subject of the next chapter.

RST, once

RST is not part of every transfer. The library holds it LOW for a moment when the sketch starts, at least 10 µs by the data sheet, then HIGH, and waits for the controller to be ready, up to 120 ms. After that it stays HIGH. Without that pulse the controller may not take the setup, and the screen stays white.

When a wire is wrong

A controller with no working clock or data never gets its setup and shows plain white. A wrong DC is worse than a missing one: commands are written into the picture as colours and colours are obeyed as commands, and the result is garbage. CS stuck HIGH is the same as no display at all.

When it does not work

Can the display share SCL and MOSI with an SD card or another display?

Yes, if each part has its own CS and only one is LOW at a time. The libraries handle that when every device is given its own CS pin. With the CS-GND jumper bridged it cannot share: it would take every byte on the bus as its own.

Can DC share a pin with anything?

No. The controller reads DC with every byte, so it must be a pin the display has to itself, driven by the display's library and nothing else.

How fast can the clock go?

The ST7735S data sheet gives 66 ns as the shortest write clock cycle, about 15 MHz. Libraries often run these panels faster, 20 to 40 MHz, and it usually works on short wires. If the picture has noise, slow it down with setSPISpeed() first.

Why is there no MISO pin?

Drawing never needs an answer from the display, so the board has no MISO and the libraries here never read anything back. Every byte goes one way, from your board to the glass.

Where this goes next

Forty thousand bytes, and how long they take on the wire.

What a frame costs →

Edit this page — content/books/tft-1-8-inch/clock-data-dc-and-cs.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

1.8-inch TFT Display

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →