GFX example not working with my St7735LCD(just white screen)

Hi all,

My SDK version:17.1

I want to use the GFX example that is in Example/peripheral with my nrf52840dk to  display some text on ST7735S LCD screen(128*160).

The code had been downloaded into the 52840dk but the LCD just had a white screen at all,nothing change.

The example code is as default,I just make one change:

  

static const nrf_lcd_t * p_lcd = &nrf_lcd_st7735;

And the pin:                    NRF52840DK           LCD pin

ST7735_SCK_PIN 47 --> P1.15                ------SCL

ST7735_MOSI_PIN 45 --> P1.13              -----SDA

ST7735_SS_PIN 44 --> P1.12                 ---------CS

ST7735_DC_PIN 42 --> P1.10                ---------DC

I don't think that the problem is on Lcd beacuse it works with  Arduino.I have read others topic about this problem but none of these work for me.Thanks!

Parents
  • Hello,

    I will have to look into more details tomorrow, as I have never tried this lcd before. But can you please try to reduce the frequency?

    In st7735.c, in the function hardware_init(), please try to add the following line directly after initialization of spi_config, and see if that helps.

    static ret_code_t hardware_init(void)
    {
        ret_code_t err_code;
    
        nrf_gpio_cfg_output(ST7735_DC_PIN);
    
        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.frequency            = NRF_DRV_SPI_FREQ_125K;
    
        spi_config.sck_pin  = ST7735_SCK_PIN;
        spi_config.miso_pin = ST7735_MISO_PIN;
        spi_config.mosi_pin = ST7735_MOSI_PIN;
        spi_config.ss_pin   = ST7735_SS_PIN;
    
        err_code = nrf_drv_spi_init(&spi, &spi_config, NULL, NULL);
        return err_code;
    }

    Best regards,

    Edvin

  • Thanks you for spending time with my problem,

    I had changed the frequency as the code you showed ,but nothing happed,my LCD screen just had white screen on it.
    But i see the LOG message on the Realterm:

    I don't know where the problem is?

  • ok. I can't tell from your picture, but you have VDD connected to your VDD pin on the DK, and not 5V, right? And GND is connected to GND? Also, can you please show me how/where you set the pin numbers that you are using?

    Can you please try to add this to your main loop to see whether it actually iterates through this loop, or if it stops somewhere? Please note that it may take longer than 1000ms for each step. At least with a low SPI speed. But we can speed this back up when we know that everything is working properly, and we can rule out the SPI speed as an issue. 

        while (1)
        {
           NRF_LOG_INFO("starting main loop");
           NRF_LOG_FLUSH();
           brackground_set();
           text_print();
           NRF_LOG_INFO("1.");
           NRF_LOG_FLUSH();
           nrf_delay_ms(1000);
           screen_clear();
           line_draw();
           NRF_LOG_INFO("2.");
           NRF_LOG_FLUSH();
           nrf_delay_ms(1000);
           screen_clear();
           circle_draw();
           NRF_LOG_INFO("3.");
           NRF_LOG_FLUSH();
           nrf_delay_ms(1000);
           screen_clear();
           rect_draw();
           NRF_LOG_INFO("4.");
           NRF_LOG_FLUSH();
           nrf_delay_ms(1000);
        }

    You said that it was working fine with the arduino. When you tested this, did you connect the reset pin? It says that the reset pin is active low, meaning if you pull it to gnd, it should reset the device, and it needs to be held high during operation. 

    Can you try to add this to operate the RST pin as well?

    static ret_code_t hardware_init(void)
    {
        ret_code_t err_code;
    
        nrf_gpio_cfg_output(ST7735_DC_PIN);
    
        nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
        spi_config.frequency            = NRF_DRV_SPI_FREQ_500K;
    
        spi_config.sck_pin  = ST7735_SCK_PIN;
        spi_config.miso_pin = ST7735_MISO_PIN;
        spi_config.mosi_pin = ST7735_MOSI_PIN;
        spi_config.ss_pin   = ST7735_SS_PIN;
    
        err_code = nrf_drv_spi_init(&spi, &spi_config, NULL, NULL);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
        
        #define ST7735_RESET_PIN 43 //P1.11
        nrf_gpio_cfg_output(ST7735_RESET_PIN);
        nrf_gpio_pin_clear(ST7735_RESET_PIN);
        nrf_delay_ms(50);
        nrf_gpio_pin_set(ST7735_RESET_PIN);
        
        return NRF_SUCCESS;
    }

    It doesn't need to be P1.11. Use any pin that isn't already in use. 

    Let me know whether any of this works or not.

    Best regards,

    Edvin

  • Oh it finally works!! 

    After i connect the RESET PIN it works(then unplugged it and get white screen),then i try to reset 52840dk for serveral times and have these three conditions:

    -Log message stop at "Starting main loop" and white screen 

    -Sometime the log message print "1,2,3,4" but the LCD is white screen

    -LCD works normally

    I think it maybe the connection is not stable that cause the problem,and the RESET PIN is really important.

    Thank you for your help!!

    Wayne

Reply
  • Oh it finally works!! 

    After i connect the RESET PIN it works(then unplugged it and get white screen),then i try to reset 52840dk for serveral times and have these three conditions:

    -Log message stop at "Starting main loop" and white screen 

    -Sometime the log message print "1,2,3,4" but the LCD is white screen

    -LCD works normally

    I think it maybe the connection is not stable that cause the problem,and the RESET PIN is really important.

    Thank you for your help!!

    Wayne

Children
No Data
Related