Arduino / LVGL / I2C problem

Description

i’m using LVGL with LovyanGFX library, on ESP32-S3 ( dev board wywy ESP32-S3-HMI-DevKit)
all works as expected, but time to time, the whole project “hang”.
i have 8 bits I2C extender and it seem the problem is here…
i read a lot of web page where LVGL is not thread safe and using some I2C devices may be a problem
(the touchscreen use the FT5X06 I2C chip)

What MCU/Processor/Board and compiler are you using?

ESP32-S3

What LVGL version are you using?

8.3.2

What do you want to achieve?

clarify the I2C problem !
not sure if i need to play with the I2C_manager file or if i need to do anything special concerning the 2C use !? (https://github.com/lvgl/lvgl_esp32_drivers

when it hang, from the terminal, i receive :
[1372241][E][wire.cpp:513] requestFrom(): i2cRead returned Error 263

here it is my config file

The code block(s) should be formatted like:

#include <LovyanGFX.hpp>

class LGFX : public lgfx::LGFX_Device
{
    lgfx::Light_PWM      _light_instance;
    lgfx::Panel_RM68120  _panel_instance;
    lgfx::Bus_Parallel16 _bus_instance;
    lgfx::Touch_FT5x06   _touch_instance;

public:

    LGFX(void)
    {
        {
            auto cfg = _bus_instance.config();

            cfg.freq_write = 30000000;

            cfg.pin_wr = 17;
            //cfg.pin_rd = 21;
            cfg.pin_rd = -1;
            cfg.pin_rs = 38;

            cfg.pin_d0  =  1;
            cfg.pin_d1  =  9;
            cfg.pin_d2  =  2;
            cfg.pin_d3  = 10;
            cfg.pin_d4  =  3;
            cfg.pin_d5  = 11;
            cfg.pin_d6  =  4;
            cfg.pin_d7  = 12;
            cfg.pin_d8  =  5;
            cfg.pin_d9  = 13;
            cfg.pin_d10 =  6;
            cfg.pin_d11 = 14;
            cfg.pin_d12 =  7;
            cfg.pin_d13 = 15;
            cfg.pin_d14 =  8;
            cfg.pin_d15 = 16;
            _bus_instance.config(cfg);
            _panel_instance.setBus(&_bus_instance);
        }

        {
            auto cfg = _panel_instance.config();
            cfg.pin_cs        =   -1;
            cfg.pin_rst       =   21;
            cfg.pin_busy      =   -1;
            cfg.dlen_16bit    = true;
            cfg.rgb_order     = true;
            cfg.memory_width  = 480;
            cfg.memory_height = 800;
            cfg.panel_width   = 480;
            cfg.panel_height  = 800;
            cfg.readable      = false;   
            _panel_instance.config(cfg);
        }

        {
            auto cfg = _touch_instance.config();
            cfg.i2c_addr   = 0x38;
            cfg.x_min      = 0;
            cfg.y_min      = 0;
            cfg.x_max      = 479;
            cfg.y_max      = 799;
            cfg.i2c_port   = 0;
            cfg.pin_sda    = GPIO_NUM_40;
            cfg.pin_scl    = GPIO_NUM_39;
            cfg.pin_int    = -1;
            cfg.freq       = 100000; // original 400000
            cfg.bus_shared = true;

            _touch_instance.config(cfg);
            _panel_instance.touch(&_touch_instance);
        }

        setPanel(&_panel_instance);
    }
};

cfg.bus_shared = true; or false don’t change anything !
i’m not sure that the problem come from the I2C driver of if it is an hardware problem on the I2C bus …

please any tips ?

thanks, regards
Phil

please, someone can explain me what is the purpose of this line :

true or false don’t change anything to my problem …
all works as expected and randomly, the program crashes with

[5724725][E][wire.cpp:513] requestFrom(): i2cRead returned Error 263 I2C ERROR : 5

thanks, regards

well, i just do a small project which include all (4) I2C chips.
removing any stuff concerning LVGL.
i do, in loop, some reads and writes to these chips.
after several hours, i don’t notice any problem !

so it seem that the problems occurs when LVGL use the I2C touchscreen chip …

anybody have same problem ? any tips please
did i manage anything concerning “thread safe stuff”

best wishes , regards

hello,

FIY, it seem that my trouble was due to the use of the library Ticker.
removing this library and manage differently the I2C access, seem to solve my issue :o)

regards

1 Like