Jump to main content

Jump to main menu

Henryk Richter

Caveats

RGB/BGR, Level Shifting etc.

Page Options
You are here: Startseite » Hardware » ILI9631 Atmel » Caveats 

Common issues

Although displays with the ST7735 controller are sold just alike, they tend to come in different flavors.

One aspect is of course the different resolution. The square displays (1.4") typically have the default resolution of 128x128. The larger 1.8" displays still work with that setting. In order to enable the higher 128x160 resolution properly, just set LCD_Height to 160 in ILI9163.h.

Another common issue affects the color layout. My first display was BGR, the second RGB. Just change ILI9163_RGB in ILI9163.h from 8 to 0 or vice versa if Red and Blue are swapped on your particular display.

Level shifting

Level Shifter variants: Voltage dividers, Ebay PCB, MC14504, 74HC4050

When it comes to interfacing modern external components, fast clocked ATmega MCUs are at a disadvantage. When driven beyond 8 MHz, a VCC of 5V is necessary. On the other hand, most external devices like LCDs operate at 3.3V. Some devices are 5V tolerant, but that can't be taken always for granted. At SPI clocks below or equal to 2 MHz, any level shifting method should suffice. When the ATmega runs at 16 MHz or more, it drives the LCD with 8 MHz and beyond.

In my initial experiments with LCDs, I always got along with simple resistor cascades. I never encountered any difficulties until I got my blue 128x160 ST7735 based LCD. That one proved way more difficult to connect than anticipated. Below you'll find the results of my experiments, along with a hopefully useful conclusion.

So, the 6.7k/10k voltage divider didn't work with that particular ST7735 LCD. I also tried to drive the LCD without the resistors. It was supposed to be 5V tolerant on the input lines but all I got was a whitewashed screen (suspected reason: clamping diodes in the ST chip). The other "usual" tricks like 10k in line or pull-up + diode (with cathode towards ATmega) also didn't work for me. In each case, the signal was badly distorted (i.e. lowpass filtering effects).

The following experiments were conducted with an overclocked ATmega 328p, running at 25 MHz (=12.5 MHz SPI clock). In the cases where I didn't obtain any output from the respective level shifting candidate with the given SPI clock, I depicted the effect on the considerably lower frequency CS signal. I apologize in advance for not giving detailed frequency response graphs.

7k/10k Level shifter with ST7735 @12 MHz
1.5k/2.2k level shifter with ST7735 @ 12 MHz

Voltage dividers

I inserted two oscilloscope screen shots on the right concerning the effect of voltage dividers in conjunction with the ST7735 LCD.

It is quite obvious that large resistors (7.5k/10k) don't work in that case, especially concering falling edges.

Another combination worked for me. I got a sufficiently suitable signal with 1.5k/2.2k resistor pairs as voltage divider. Another possible pairing is 470/680 Ohm. The cost of that setup is a quite high current on the SPI lines with 1.5 mA in the first variant or or >4.3 mA in the second variant.

So if anyone is not willing to insert another chip into the setup, lowering the voltage divider resistors might be a possible choice.

74HC4050, MC14504B

MC14504B as level shifter, way too slow
74HC4050 as level shifter, nicely looking signal

Well, the datasheet for the MC14054B I had for disposal was not encouraging. Typical propagation delays around 200ns are not what I was looking for. I included the chip in my tests anyway. As expected, it didn't work at all with 12 MHz SPI clock. The picture on the right shows the behavior with the chip select signal. It is obvious that the MC14054B doesn't cut it for the task I had in mind.

In the end, I obtained the best results with a 74HC4050 as unidirectional level shifter. The inputs are 5V tolerant, even when VCC is at 3.3V. The chip itself doesn't need anything more in terms of components than just the power supply. The picture should speak for itself. The 74HC4050 handles the 12 MHz SPI clock just fine.

There is one catch, however. The speed of the 4050 depends on VCC. According to the datasheet, the maximum propagation delay at VCC 2V is 160ns. The time reduces to 32ns at VCC 4.5V. In order to perform well, the supply voltage for the chip should be as high as permissible.

Summary

The solution could have been easy: Use something like an STM32 instead of ATmega, obtain considerably higher SPI speeds and get rid of the level shifting necessity as the modern MCUs work with 3.3V natively at all speeds.

If one stays with ATmega and stumbles over a display with inputs of high capacitance, my (limited) experiments might be somewhat useful.

Bottom line is: In case of display connectivity issues, try to drive them with low SPI speeds first to verify correct cabling. It might be necessary to change resistor cascades towards lower resistances at higher SPI speeds. Furthermore, my personal favorite for unidirectional level shifting applications so far, is the 74HC4050.