esp32 wrrom 32E with esp idf I2C master
Posted: Mon Oct 07, 2024 11:30 am
m using a esp32wroom 32E with the IDE and I'm trying to write to the slave some data, I write the code :
Which works OK if I just use the master probe to test if the slave device is detected....now if I use
I got nothing on the scope, nothing and a bunch of warning just like this old thread http://esp32.io/viewtopic.php?p=133297
the esp32 reboot again and again......
the PID and data are uint8_t variables
why?
why the master transmite recibe is not working if the master probe detect the slave?
Regards
Gastón
Code: Select all
i2c_master_bus_config_t master_cfg={
.i2c_port = I2C_NUM_0,
.scl_io_num = MASTER_I2C_SCL,
.sda_io_num = MASTER_I2C_SDA,
.glitch_ignore_cnt = 0,
.clk_source = I2C_CLK_SRC_DEFAULT
};
i2c_master_bus_handle_t bus_handle;
ESP_ERROR_CHECK(i2c_new_master_bus(&master_cfg,&bus_handle));
//ESP_ERROR_CHECK(i2c_master_probe(bus_handle, 0x21, -1));
ESP_LOGD(TAG,"I2C master probe");
//config device slave
i2c_device_config_t device_cfg={
.device_address = 0x21,
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
.scl_speed_hz = MASTER_I2C_CLOCK
};
i2c_master_dev_handle_t dev_handle;
ESP_ERROR_CHECK(i2c_master_bus_add_device(bus_handle,&device_cfg,&dev_handle));
Code: Select all
ESP_ERROR_CHECK(i2c_master_transmit_receive(dev_handle, PID, sizeof(PID), sizeof(data), 1, -1));
the esp32 reboot again and again......
the PID and data are uint8_t variables
why?
why the master transmite recibe is not working if the master probe detect the slave?
Regards
Gastón