I2C Problem initializing on pin33 and pin36

kacie_23
Posts: 5
Joined: Fri Nov 22, 2019 7:21 pm

I2C Problem initializing on pin33 and pin36

Postby kacie_23 » Fri Nov 29, 2019 8:28 pm

Hello,

I have a problem initialising the master i2c on my ESP32wroom32

I have connected I2C lines on Pin33 and Pin36 (I2C_Data, I2C_Clock respectively).
These pins seem to be connected to GPIO8, and GPIO23.

GPIO8 seem to be the problem, since this pin has funciton1 as SD_DATA1, and function2 as GPIO8.

If I remove the GPIO8, and just select some unused GPIO, the initialisation works, but without any communication of course.

Whenever I introduce the GPIO8 in the initialising code, the CPU panics.
I assume that the I2C_MODE_MASTER is either 0 or 1, and I can freely choose this number.
I2C_DATA_GpioPortNr = GPIO_NUM_8
I2C_CLOCK_GpioPortNr= GPIO_NUM_23
trace.txt
(1.35 KiB) Downloaded 417 times

Code: Select all

esp_err_t sensorClass::i2c_master_init(void)
{
    esp_err_t lv_errorVal;

    i2c_config_t conf;
    conf.mode = I2C_MODE_MASTER;
    conf.sda_io_num = I2C_DATA_GpioPortNr;
    conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
    conf.scl_io_num = I2C_CLOCK_GpioPortNr;
    conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
    conf.master.clk_speed = I2C_frequency;
        
    lv_errorVal = i2c_param_config(I2C_Master_Port, &conf);
    if (lv_errorVal != 0) 
        printf("I2C init - %s : Parmeter config error\n", esp_err_to_name(gv_errVal)); 

    lv_errorVal = i2c_driver_install(I2C_Master_Port, conf.mode, I2C_MASTER_RX_BUF_DISABLE,I2C_MASTER_TX_BUF_DISABLE, 0);
    if (lv_errorVal != 0) 
        printf("I2C init - %s : Driver install error\n", esp_err_to_name(gv_errVal)); 
    
    return lv_errorVal;
}

ESP_Sprite
Posts: 9599
Joined: Thu Nov 26, 2015 4:08 am

Re: I2C Problem initializing on pin33 and pin36

Postby ESP_Sprite » Sat Nov 30, 2019 2:59 am

GPIO8 is used by the flash the ESP32 is running your program from. Don't use that.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: I2C Problem initializing on pin33 and pin36

Postby WiFive » Sat Nov 30, 2019 8:10 am

In fact you should avoid all Flash pins 6-11

kacie_23
Posts: 5
Joined: Fri Nov 22, 2019 7:21 pm

Re: I2C Problem initializing on pin33 and pin36

Postby kacie_23 » Thu Dec 12, 2019 5:41 am

The datasheet for the ESP32 is different from the datasheet ESP32wroom32, making the answer quite stupid since it is only a result of confusion.

When establishing the GPIO_NUM_xx for the entry of the I2C pin numbers it was corrected properly when looking at the PIN-setup for the wroom module.

Code: Select all

//Correct entry for the master init of I2C - at pin33 and pin36
initI2C.i2c_master_init(I2C_NUM_0,GPIO_NUM_21,GPIO_NUM_22); 

Who is online

Users browsing this forum: No registered users and 120 guests