ESP32 IDF V4 - Issue I2C Setup

Posted on
  • An error occurs using espruino in the ESP32-C3 IDF 4 build. when setting up the i2C. In more detail: When building with the command line:

    BOARD=ESP32C3_IDF4 DEBUG=1 make flash BINDIR=.
    

    The error occurs when executing the espruino command:

    I2C1.setup({scl:D9,sda:D8});
    

    The error text is :

    i2c: i2c_param_config(684): i2c clock choice is invalid, please check
    flag and frequency

    Uncaught Error: jshI2CSetup: Invalid arguments at line 1 col 27

    I2C1.setup({scl:D9,sda:D8});


    1 Attachment

    • i2C Error.png
  • This link seems to identify the problem. An indeed tracing the error message back into the code shows that the ESP IDF i2c driver (see image for source file name) is expecting to be passed a clocks variable in the config structure from espruino jshardwareI2c.c

    I am testing a fix which will need to be ifdef out for the idf4 build. It also involves handling the i2C speed that Espruino allows to be set in the I2C.setup function. PR to follow.
    Im setting up a local clone of Espruino to test the builds (including ESP32 idf V3) after the change to be sure the ESP32 old version still builds and executes I2C.


    1 Attachment

    • i2cError2.png
  • Thanks for tracking that down - that sounds great!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

ESP32 IDF V4 - Issue I2C Setup

Posted by Avatar for SimonGAndrews @SimonGAndrews

Actions