Adafruit STR7735R 1.8" display help - Page 1
Forum section: electronics / general

author: Boscoe
author_rank: Frequent Contributor
timestamp: November 08, 2015, 11:12:24 am
content: Hi I'm running into a problem with this display.I've written some C code for an STM32F4 dev board to communicate with this display via SPI but I can't seem to get any life out of it.I know my code works because I'm decoding the SPI on my scope.The documentation from adafruit is awful - that bad this product doesn't have a part number from themselves. I'm using the 4 wire serial which is about the only bit of information given from Adafruit.Basically I'm not sure on how to initialize this display as I find the datasheet to be very vague. From what I can gleam from the datasheet and Adafruit's libraries you can simply start writing to the display RAM and once it's full the controller displays the image, but this doesn't work. I've tried sending the 'RAM WRITE' command then start writing of SPI but still nothing. I've tried sending commands like 'DISPLAY ON' and 'DISPLAY OFF' as well as display inversion to try to tell whether the display is receiving data but I get nothing.Does anyone have any experience with this display where they can help me?ThanksPS Display linkhttp://www.adafruit.com/products/358Datasheet:http://www.adafruit.com/datasheets/ST7735R_V0.2.pdf

author: Kalvin
author_rank: Super Contributor
timestamp: November 08, 2015, 11:22:30 am
content: You may want to look at this code from Adafruit and try to figure out what the display driver is doing.https://github.com/adafruit/Adafruit-ST7735-LibraryThe file Adafruit_ST7735.cpp has a table of initialization commands and values, which are written to the display after reset/power-up.Check also that your the voltage level of your SPI signals are right. I have used SPI displays with 3V3 interface with 5V Arduino, and the interface requires series resistors or level shifters to work correctly.

author: obiwanjacobi
author_rank: Super Contributor
timestamp: November 08, 2015, 11:42:26 am
content: I have used the AdaFruit driver with a 1.8" display (same datasheet) successfully.(Only I am unsure what library I used exactlyI See that I have TFTLCD on my system... - but that may be for another LCD I played with?)You say you have "a problem" and "get nothing" - can you be a bit more specific in what your problem actually is? (or I don't get what you're writing)One mistake I made was that you need to put a pot (or PWM? - haven't tried that) on BL to trim the backlight intensity.After that it worked in one go. I used the example sketch that came with the AdaFruit driver.

author: Boscoe
author_rank: Frequent Contributor
timestamp: November 08, 2015, 01:39:48 pm
content: Okay thank you both for the feedback. I have gone through the initialization that is in the Adafruit libraries for the Blacktab parameter. I don't know whether this is the right option but again the documentation is poor for the libraries so I didn't know which to use so I went with the simplest.This is my initialization followed by my write to the memory://Display initializationvoid init_display(void){uint8_t command; //Initialize send bufferuint8_t data; //Initialize send buffer// 1: Software reset, 0 args, w/150 ms delaycommand = ST7735_SWRESET;TFT_Write(command, 1, CMD);delay(150);// 2: Out of sleep mode, 0 args, w/500 ms delaycommand = ST7735_SLPOUT;TFT_Write(command, 1, CMD);delay(500);// 3: Frame rate ctrl - normal mode, 3 args: Rate = fosc/(1x2+40) * (LINE+2C+2D)command = ST7735_FRMCTR1;data = 0x01;data = 0x2C;data = 0x2D;TFT_Write(command, 1, CMD);TFT_Write(data, 3, DATA);// 4: Frame rate control - idle mode, 3 args: Rate = fosc/(1x2+40) * (LINE+2C+2D)command = ST7735_FRMCTR2;data = 0x01;data = 0x2C;data = 0x2D;TFT_Write(command, 1, CMD);TFT_Write(data, 3, DATA);// 5: Frame rate ctrl - partial mode, 6 args: Dot inversion mode, Line inversion modecommand = ST7735_FRMCTR3;data = 0x01;data = 0x2C;data = 0x2D;data = 0x01;data = 0x2C;data = 0x2D;TFT_Write(command, 1, CMD);TFT_Write(data, 6, DATA);// 6: Display inversion ctrl, 1 arg, no delay: No inversioncommand = ST7735_INVCTR;data = 0x07;TFT_Write(command, 1, CMD);TFT_Write(data, 1, DATA);// 7: Power control, 3 args, no delay: -4.6V, Autocommand = ST7735_PWCTR1;data = 0xA2;data = 0x02;data = 0x84;TFT_Write(command, 1, CMD);TFT_Write(data, 3, DATA);// 8: Power control, 1 arg, no delay: VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDDcommand = ST7735_PWCTR2;data = 0xC5;TFT_Write(command, 1, CMD);TFT_Write(data, 1, DATA);// 9: Power control, 2 args, no delay: Opamp current small, Boost frequencycommand = ST7735_PWCTR3;data = 0x0A;data = 0x00;TFT_Write(command, 1, CMD);TFT_Write(data, 2, DATA);// 10: Power control, 2 args, no delay: BCLK/2, Opamp current small & Medium lowcommand = ST7735_PWCTR4;data = 0x8A;data = 0x2A;TFT_Write(command, 1, CMD);TFT_Write(data, 2, DATA);// 11: Power control, 2 args, no delaycommand = ST7735_PWCTR5;data = 0x8A;data = 0xEE;TFT_Write(command, 1, CMD);TFT_Write(data, 2, DATA);// 12: Power control, 1 arg, no delay:command = ST7735_VMCTR1;data = 0x0E;TFT_Write(command, 1, CMD);TFT_Write(data, 1, DATA);// 13: Don't invert display, no args, no delaycommand = ST7735_INVON;TFT_Write(command, 1, CMD);// 14: Memory access control (directions), 1 arg:command = ST7735_MADCTL;data = 0xC0;TFT_Write(command, 1, CMD);TFT_Write(data, 1, DATA);// 15: set color mode, 1 arg, no delay:command = ST7735_COLMOD;data = 0x05;TFT_Write(command, 1, CMD);TFT_Write(data, 1, DATA);}//Draw a bitmap to the displayvoid draw_bmp_display(uint8_t* TxBuffer){uint8_t colstart = 2;uint8_t rowstart = 1;uint8_t command; //Initialize send bufferuint8_t data; //Initialize send buffercommand = ST7735_CASET;data = 0x00;data = colstart;data = 0x00;data = colstart + 159;TFT_Write(command, 1, CMD);TFT_Write(data, 4, DATA);command = ST7735_RASET;data = 0x00;data = rowstart;data = 0x00;data = rowstart + 127;TFT_Write(command, 1, CMD);TFT_Write(data, 4, DATA);command = ST7735_RAMWR;TFT_Write(command, 1, CMD);for(int lines = 0; lines < 165; lines ++){ //Just a test for now dumping values to the memory.TFT_Write(TxBuffer, 128, DATA);}}

author: obiwanjacobi
author_rank: Super Contributor
timestamp: November 08, 2015, 02:03:53 pm
content: But what do you see? What makes you think it doesn't work?

author: Boscoe
author_rank: Frequent Contributor
timestamp: November 08, 2015, 02:13:02 pm
content: Nothing happens to the display when the data is written. I'm writing all zeros so I expect it to turn black or white. Neither happens even if I enable display inversion.

author: amyk
author_rank: Super Contributor
timestamp: November 08, 2015, 02:23:38 pm
content: A version0.2datasheet is all they have, when there's av1.4out already?Anyway the ST7735(R) is a"big Philips"type controller (similar to the old PCF8833) so if you find code for any of that family it should work. The datasheet describes the power-on process starting in section 9.13. After power-on and hardware reset you need to issue commands software reset, delay 120ms, sleep out, delay 120ms, display on. The other settings usually don't need to be changed unless you want to fine-tune the display appearance. Make sure the interface selection is correct.Also, Adafruit is overpriced. You can get the same type of display elsewhere for cheaper.

author: Boscoe
author_rank: Frequent Contributor
timestamp: November 08, 2015, 02:36:08 pm
content: Thanks for that it's good help! However, in the link for the v1.4, there is no section 9.13.

author: amyk
author_rank: Super Contributor
timestamp: November 08, 2015, 02:37:52 pm
content: Did you look at page 68?

author: Boscoe
author_rank: Frequent Contributor
timestamp: November 08, 2015, 03:00:03 pm
content: Sorry I didn't think section 9 would go on for so long!

author: andyturk
author_rank: Frequent Contributor
timestamp: November 08, 2015, 04:31:24 pm
content: I played with these displays a while ago and got a couple of different versions to work. The init sequences I used are here:https://github.com/andyturk/libakt/blob/master/akt/views/st7735r.ccYour code is using a different MADCTL (0xc0) than mine (0xa8), so you might try changing that.

author: Boscoe
author_rank: Frequent Contributor
timestamp: November 08, 2015, 07:45:36 pm
content: Thanks for the help everyone. It was the crucial 'turn display on' command I was missing. It's working nicely now!

author: Kalvin
author_rank: Super Contributor
timestamp: November 08, 2015, 08:05:02 pm
content: Quote from: Boscoe on November 08, 2015, 07:45:36 pm