Elecrow Display 5inch with CAN modul connected through I2C

hi everyone,
i am currently developing a control screen project for electric bicycles. and having problems connecting CAN module via I2C port on the screen. i am using elecrow 5inch touchdisplay and squreline studio for design, (i use main.ino and fxconfig.h file from demo code) and I2C CAN module from Longan. if i just connect the screen to CAN module then everything works fine, i can nhajanvaf decode can frame. however after combining with demo code (.ino and fxconfig.h) with export design code then esp32 can no longer receive and decode can data even though no error occurs. when checking again i see that I2C GPIO19 and 20 are used for both touch sensor and external I2C connection port. i want to ask if it is possible to use touch screen and external device at the same time via I2C connection to the screen

Comments

  • Dear minhduc,
    I hope this message finds you well. Thank you for reaching out. Sorry for the inconvinience caused.

    Our technical support team is currently looking into the issue in your message. Please be patient, and we will get back to you as soon as possible.

    Thanks! Have a nice day!

  • Dear minhduc,
    The I2C port can only use the I2C module, not the CAN module. Because the corresponding pins have been used by the touch screen, they can only be used as I2C.
    Thanks! Have a nice day!

  • You can´t use the same port for both. You need to hijack the I2S port for use with CAN. It involves soldering cables to the pins as they are not brought out to a socket. I asked if this can be changed on the next version of the display as it would make things much easier.
    On the original display the pins are GPIO17 and GPIO18. On the advanced board they are GPIO4 and GPIO5, plus you need to set the switch for MIC & SPK. As the I2S chip is a consumer of data it does not conflict with the CAN transceiver (I use the VP230 transceiver without any problems). If of interest I use the ESP32 TWAI driver for my CAN communication.

  • edited May 29

    Ah, now I see you are using an I2C CAN module. I can take a guess..
    It might be that LVGL is setting up RTOS tasks to communicate with the touch screen so you are conflicting with access.
    You could create an RTOS task for your CAN module and then control access to the I2C bus using mutex semaphores. This would ensure there are no conflicting attempts to access the I2C bus at the same time. You would need to add mutex access to the I2C bus in the touch screen code generated by LVGL.
    I use this method extensively with RTOS tasks.
    It´s only a guess that this is what is happening - I don´t use LVGL as I find it too controlling - I use LovyanGFX instead.
    Hope this helps.

Sign In or Register to comment.