cancel
Showing results for 
Search instead for 
Did you mean: 

st7789h2 LCD MODULE issues

MRedd.3
Associate II

hello sir,

My self-Mahesh firmware engineer

Currently I am working with 1.54 inch display module(st7789h2),This module is configured with four wire SPI.

I am facing some issues

1, Pixel writing is very slow.

2, Not able to control the brightness.

3, I am able to write only full image(240*240)

Pixel writing is very slow:

I am able to display the test and image, however writing speed is very slow ,to write full image (240 *240) pixel its taking around 4min. we tried to change frame rate value (00 to FF )in C6h register ,still pixel writing speed remains same. Please find the attached video file you can see the how the pixel writing.

Kindly let me know how to increase the pixel speed.

Not able to control the brightness:

We are setting the BCTRL bit to enable the brightness control blank in 53h register, Display control register (51h) DBV0-7 value we tried to change it from min to max ,however brightness remains same. Any other register need to be set.

I am able to write only full image(240*240):

To get bitmapping image data(16bit) I am using LCD image converter tool. When we tried to write full image( 240*240) its displaying properly,

but when we tried to write 100 *100 Pixel it’s not displaying as expected.

anyone have any idea please help to resolve this issue

Thanks & Regards,

Mahesh

11 REPLIES 11
MM..1
Chief II

What code what MCU ???

Presumably there's a datasheet for the part, and display combo, review those thoroughly.

Check the rate you're clocking the SPI, use a scope and check, or look at the settings, and understand them.

If the image is slewing you have the horizontal width wrong, here it looks too short.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi sir,

Thank you for reply,

I was able to fix the image problem. Now I'm attempting to raise the pixel speed, with the SPI CLK speed set to 1 MHz and the frame rate set at 60 Hz.

I also tested different frame rates, but the pixel pace remained the same.

Could you please give me some suggestions?

Thanks& Regards

Reddy

Hi sir,

I'm using a LCD module t7789h2 with a nrf MCU. I can display the image, but pixel write is slow, which I'm trying to fix.

I'm going to share my LCD initialize configuration method with you, and I'm hoping you can help me fix this problem.

void lcd_init_st7789h2(void)

{

  uint8_t parameter[14];

  hardware_init(); 

  nrf_gpio_pin_set(8);

  nrf_delay_ms(500);

  nrf_gpio_pin_clear(8);

  nrf_delay_ms(120);

  nrf_gpio_pin_set(8);

  // initialize st7789h2 low level bus layer

 // LCD_IO_Init();

   write_command(ST7789H2_SLEEP_IN);

  //nrf_delay_ms(500);

  // SW reset command

  write_command(0x01);

  //nrf_delay_ms(500);

  write_command(ST7789H2_SLEEP_OUT);

  //nrf_delay_ms(120);

  parameter[0] = 0x80;

  write_command(0x55);    // write content briteness control & color enhancement

  write_data(parameter,1);

  nrf_delay_ms(300); 

  parameter[0] = 0x00;

  write_command(0xCC);

  write_data(parameter,1);

  //nrf_delay_ms(300);

 // spi_read(ST7789H2_PWM_CTRL);

  // normal display for driver down side

  parameter[0] = 0x20;

  write_command(ST7789H2_NORMAL_DISPLAY);

  write_data(parameter,1);

  //nrf_delay_ms(300);

  // color mode 16bit / pixel

  parameter[0] = 0x55;

  write_command(ST7789H2_COLOR_MODE);

  write_data(parameter,1);

  //nrf_delay_ms(300);

  // display inversion On

  write_command(ST7789H2_DISPLAY_INVERSION);

  //nrf_delay_ms(300);

  lcd_set_cursor(0, 0);

  //nrf_delay_ms(300);

  // ST7789H2 frame rate setting

  // PORCH control setting 

  parameter[0] = 0x0C;  // 0c 

  parameter[1] = 0x0C;  // 0c

  parameter[2] = 0x00;

  parameter[3] = 0x33;

  parameter[4] = 0x33;

  write_command(ST7789H2_PORCH_CTRL);

  write_data(parameter,5);

  //nrf_delay_ms(300);

  // GATE control setting

  parameter[0] = 0x35;

  write_command(ST7789H2_GATE_CTRL);

  write_data(parameter,1);

  //nrf_delay_ms(300);

  // ST7789H2 power setting

  // VCOM setting

  parameter[0] = 0x1F;

  write_command(ST7789H2_VCOM_SET);

  write_data(parameter,1);

  // LCM Control setting

  parameter[0] = 0x2C;

  write_command(ST7789H2_LCM_CTRL);

  write_data(parameter,1);

  //nrf_delay_ms(300);

  // VDV and VRH command enable

  parameter[0] = 0x01;

  parameter[1] = 0xC3;

  write_command(ST7789H2_VDV_VRH_EN);

  write_data(parameter,2);

  //nrf_delay_ms(300);

  // VDV set

  parameter[0] = 0x20;

  write_command(ST7789H2_VDV_SET);

  write_data(parameter,1);

  //nrf_delay_ms(300);

  // frame rate control in normal mode

  parameter[0] = 0x7F;

  write_command(ST7789H2_FR_CTRL);

  write_data(parameter,1);

  //nrf_delay_ms(300);

  // power control

  parameter[0] = 0xA4;

  parameter[1] = 0xA1;

  write_command(ST7789H2_POWER_CTRL);

  write_data(parameter,2);

  //nrf_delay_ms(300);

  parameter[0] = 0xB3;

  write_command(0x55);

  write_data(parameter,1);

   //nrf_delay_ms(300);

   parameter[0] = 0x00;

  write_command(0x51);

  write_data(parameter,1);

   //nrf_delay_ms(300);

  //parameter[0] = 0x20;

  write_command(0x12);

  //write_data(parameter,1);

  //nrf_delay_ms(300);

  //nrf_delay_ms(300);

  

  // ST7789H2 gamma setting

  parameter[0] = 0xD0;

  parameter[1] = 0x08;

  parameter[2] = 0x11;

  parameter[3] = 0x08;

   

  // positive voltage gamma control

  parameter[4] = 0x0C;

  parameter[5] = 0x15;

  parameter[6] = 0x39;

  parameter[7] = 0x33;

  parameter[8] = 0x50;

  parameter[9] = 0x36;

  parameter[10] = 0x13;

  parameter[11] = 0x14;

  parameter[12] = 0x29;

  parameter[13] = 0x2D;

  write_command(ST7789H2_PV_GAMMA_CTRL);

  write_data(parameter,14);

  nrf_delay_ms(300);

  // negative voltage gamma control

  parameter[4] = 0x06;

  parameter[5] = 0x06;

  parameter[6] = 0x39;

  parameter[7] = 0x44;

  parameter[8] = 0x51;

  parameter[9] = 0x0B;

  parameter[10] = 0x16;

  parameter[11] = 0x14;

  parameter[12] = 0x2F;

  parameter[13] = 0x31;

  write_command(ST7789H2_NV_GAMMA_CTRL);

  write_data(parameter,14);

  nrf_delay_ms(300);

  lcd_display_on();

  // tearing effect line on: option (00h:VSYNC interface OFF, 01h:VSYNC interface ON)

  parameter[0] = 0x01;

  write_command(ST7789H2_TEARING_EFFECT);

  write_data(parameter,1);

  nrf_delay_ms(300);

// tearing modes

parameter[0] = 0;

parameter[1] = 0b11000000;

  //write_command(ST7789H2_RDDSM);

  //write_data(parameter,2);

}

So not an STM32 MCU, but a Nordic one

Doesn't show any of the SPI configuration or transport code.

Get a scope, check the clock, check the timing of the different communication bursts.

You seem to have a lot of arbitrary delays, if you accumulate 300ms with every bus transaction you're going to get to seconds and minutes rather quickly. That's going to be an age compared to sending a dozen bytes at 1 MHz.

Make sure you consolidate transactions so you aren't sending byte or pixels at a time, but whole rows or buffers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Maybe you need calculate 240x240x16x60 is dotclock required for stream your config over spi equal around 60MHz

On SPI display is internal framerate diferent as count of frames received over SPI ... but normal SPI is 10-30MHz

And we dont need see init code , but write_data and write _image ...

Yes, sir, we are using a nordic nrf52 MCU instead of a stm32.

I've tested several spi speeds ranging from 1mhz to 32 mhz, but the pixel writing speed remains the same.

I wrote delays in the device config function, which I shared above. The extent of spi clock siganls verified.

Please take a look at the picture data written function.

void draw_RGB_image (uint16_t x_pos, uint16_t y_pos, uint16_t x_size, uint16_t y_size, uint16_t const * data)

{

 uint16_t x_size1, y_size1;

x_size1=x_size;

y_size1 = y_size;

  lcd_set_region(x_pos, y_pos, x_size, y_size);

  // prepare to write to LCD RAM

  write_command(ST7789H2_WRITE_RAM);

 //write_data((uint8_t*)data, sizeof(*data) * x_size1 * y_size1);

  for (uint32_t i = 0; i != (x_size1 * y_size1); ++i)

    write_2byte_data(data[i]);

}

MM..1
Chief II
void draw_RGB_image (uint16_t x_pos, uint16_t y_pos, uint16_t x_size, uint16_t y_size, uint16_t const * data)
{
 uint16_t x_size1, y_size1;
x_size1=x_size;
y_size1 = y_size;
 
  lcd_set_region(x_pos, y_pos, x_size, y_size);
  // prepare to write to LCD RAM
  write_command(ST7789H2_WRITE_RAM);
 
 //write_data((uint8_t*)data, sizeof(*data) * x_size1 * y_size1);
 
  for (uint32_t i = 0; i != (x_size1 * y_size1); ++i)
    write_2byte_data(data[i]);

Ahh maybe you are mythic person , imnt try show complete code to last communication level ...

H sir ,

Please take a look at the communication code and let me know if you have any suggestions.

I'm working on an LCD for the first time, and I'm not sure what the problem is.

I'm not sure why you called me mthic .

void draw_RGB_image (uint16_t x_pos, uint16_t y_pos, uint16_t x_size, uint16_t y_size, uint16_t const * data)

{

 uint16_t x_size1, y_size1;

x_size1=x_size;

y_size1 = y_size;

  lcd_set_region(x_pos, y_pos, x_size, y_size);

  // prepare to write to LCD RAM

  write_command(ST7789H2_WRITE_RAM);

 //write_data((uint8_t*)data, sizeof(*data) * x_size1 * y_size1);

  for (uint32_t i = 0; i != (x_size1 * y_size1); ++i)

    write_2byte_data(data[i]);

}

void spi_write(const uint8_t * data, uint8_t size)

{

   spi_xfer_done=false;

    APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi,data,size,NULL,0));

    while(spi_xfer_done == false){};

}

///////////////////////////////////////////////////////

/* write the command byte */

uint8_t write_command(uint8_t c)

{

  nrf_gpio_pin_clear(ST7735_DC_PIN);

  spi_write(&c, sizeof(c));

}

/* write the data byte */

uint8_t write_data(uint8_t *data, uint16_t n_data_byte)

{

  nrf_gpio_pin_set(ST7735_DC_PIN);

  spi_write(data, n_data_byte);

}

 uint8_t write_2byte_data(uint16_t value)

{

  uint8_t data[2];

  uint16_t n_data_byte=2;

  data[0]=(uint8_t*)(value>>8);

  data[1]=(uint8_t*)(value);

  nrf_gpio_pin_set(ST7735_DC_PIN);

  spi_write(data, n_data_byte);

}

void lcd_set_region (uint16_t x_pos, uint16_t y_pos,const uint16_t x_size,const uint16_t y_size)

{

  uint8_t parameter[4];

  parameter[0] = 0x00;

  parameter[2] = 0x00;

  // comumn addrses set

  parameter[1] = x_pos;

  parameter[3] = x_pos + x_size;

  write_command(ST7789H2_CASET);

  write_data(parameter,4);

  // row addrses set

  parameter[1] = y_pos;

  parameter[3] = y_pos + y_size;

  write_command(ST7789H2_RASET);

  write_data(parameter,4);

}

Thanks &Regards