is there any issue using io0/io4 for i2c?
is there any issue using io0/io4 for i2c?
I am trying to use IO0 for SDA and IO4 for SCL in I2C. I have tried with 4.7k external pullups in both pins and no pullups as well. I2cscanners fail to connect to sensors. When I am using other pins everything works fine. Any ideas?
Re: is there any issue using io0/io4 for i2c?
IO0 is a special pin that already has a pullup on it. Its used to program the part. I suggest looking at the data sheet first so you can understand what pins to use and not to.
Re: is there any issue using io0/io4 for i2c?
Hi,
I know how they function, nevertheless in the esp32 docs they say that after boot they behave like normal pins. I do use them for the boot process but it doesnt seem to be working, while the same software when its using other pins is working
I know how they function, nevertheless in the esp32 docs they say that after boot they behave like normal pins. I do use them for the boot process but it doesnt seem to be working, while the same software when its using other pins is working
Re: is there any issue using io0/io4 for i2c?
Not sure, Personally I steer clear of using GPIO0. Throw a scope on the SCL/SDA lines and have a look.
Re: is there any issue using io0/io4 for i2c?
Pretty sure that GPIO 0 is available after boot. If you are going work on stuff like this it's worth getting a cheap scope to analyze these kinds of problems.
John A
John A
Re: is there any issue using io0/io4 for i2c?
there are not enough pins on esp32. I am already using port expanders, multiple multiplexers on that pcb. I need to make them work I will look with my trusted rigol. I was trying to determine if there is something internal that prohibits them to be used as i2c. they have internal pullups, they are IO (unlike >io34). so after boot they should work. right? the same software on different pins works like a charm
Re: is there any issue using io0/io4 for i2c?
This is the code that I am running. I put a scope on IO0 and I get the attached signal. the same program on another pin works like a charm.
Code: Select all
void task_i2cscanner(void *ignore)
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
ESP_LOGD("Sensor", ">> i2cScanner");
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = SCL_PIN;
conf.scl_io_num = SDA_PIN;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = 400000;
i2c_param_config(I2C_NUM_0, &conf);
i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0);
while (true)
{
vTaskDelay(1);
int i;
esp_err_t espRc;
printf(" SDA_PIN %i SCL_PIN %i\n", conf.sda_io_num, conf.scl_io_num);
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n");
printf("00: ");
for (i = 3; i < 0x78; i++) {
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (i << 1) | I2C_MASTER_WRITE, 1 /* expect ack */);
i2c_master_stop(cmd);
espRc = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_PERIOD_MS);
if (i % 16 == 0) {
printf("\n%.2x:", i);
}
if (espRc == 0) {
printf(" %.2x", i);
}
else {
printf(" --");
}
//ESP_LOGD(tag, "i=%d, rc=%d (0x%x)", i, espRc, espRc);
i2c_cmd_link_delete(cmd);
}
printf("\n");
}
//vTaskDelete(NULL);
}[Codebox=cpp file=Untitled.cpp][/Codebox]
- Attachments
-
- io0_i2c.jpg (155.66 KiB) Viewed 10527 times
Re: is there any issue using io0/io4 for i2c?
You never want to use internal pullups for I2C on ANY device. They will all be too weak to do the job properly.
Who is online
Users browsing this forum: No registered users and 69 guests