i2c randombly fails
Re: i2c randombly fails
Sorry for the misunderstanding on what you were asking. My driver still works around them but I have not tested yet whether I need to work around them or not. I'll let you know when I get a chance to test it.
Re: i2c randombly fails
Hi
Thanks - I have been look for that fix for a very long time - and even considering using a soft i2c driver.
No more random fails on i2c. Change from _FLASH to _RAM did the job.
Regards Jakobsen
Thanks - I have been look for that fix for a very long time - and even considering using a soft i2c driver.
No more random fails on i2c. Change from _FLASH to _RAM did the job.
Code: Select all
...
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
...
Analog Digital IC designer / DevOps @ Merus Audio, Copenhagen, Denmark.
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then
We do novel and best in class Audio amplifiers for consumer products.
Programmed assembler for C-64 back in 1980's, learned some electronics - hacking since then
Re: i2c randombly fails
Wow that is strange WIFI_STORAGE_FLASH can break i2c.
Re: i2c randombly fails
Hi,
i really hoped that this fix is going to help me with my I2C problems (mainly the SCL gets stuck or keeps clocking forever sometimes in the first seconds after a power-on, only way to recover is a module reset). Once the I2C bus works for the first couple of seconds it seems to be stable for a long time so far.
Unfortunately i recognized that is already used in my code. I am happy this fix improves some parts of the I2C part but probably there still are some more issues.
Regards,
Markus
i really hoped that this fix is going to help me with my I2C problems (mainly the SCL gets stuck or keeps clocking forever sometimes in the first seconds after a power-on, only way to recover is a module reset). Once the I2C bus works for the first couple of seconds it seems to be stable for a long time so far.
Unfortunately i recognized that
Code: Select all
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
Regards,
Markus
-
- Posts: 59
- Joined: Thu Jan 19, 2017 5:17 pm
Re: i2c randombly fails
As Markus said, the problem still exists for me even with the wifi change. The SCL line clocks forever until I reset. The values I get back from my MCP23017 i2c device are wrong and take longer to get back than normal. I believe there is a fluctuation in the power or interference from relays close by which switch 120vac main lines. I can simulate the issue by pulling the i2c lines to ground for a second.
Re: i2c randombly fails
Hi @jesseb ,
Read your comments on the I2C driver and your simplified replacement. I am at wits end with the ESP32 and I2C, my situation is as follows:
* Custom designed hardware using genuine Rev1 WROOM modules
* 8x LEDs and 8x relays attached to an I2C GPIO extender.
* implementing soft PWM (fadeIn, On, FadeOut, Off) functionality in a dedicated task running at 1ms (i tick) intervals
* based on the specific timing and stage each bit is toggled on and off.
* DS2482-800 I2C to 1-Wire (8 channel ) bridge reading iButtons for access and resource control
* DS2482-800 is read every 1 sec (1000 ticks)
Originally I wrote each bit change (only changes) using an individual I2C write. Very quickly this crashed the I2C bus when all 16 actuators running. I then changed to buffer all bit changes for a full cycle of all 16 actuators, and then only write the full 16 bit-mapped GPIO states to the GPIO expander in a single 16 bit write.
This reduced I2C activity hugely, but I still on a completely irregular basis have the I2C bus freeze and the GPIOs/actuators go into random states.
My questions are as follows:
1) Have you had reasonable success with your simplified I2C driver?
2) If so, can you please share the latest version with me so I can try to port my actuator engine to run on your driver instead?
All feedback much appreciated,
Andre
Read your comments on the I2C driver and your simplified replacement. I am at wits end with the ESP32 and I2C, my situation is as follows:
* Custom designed hardware using genuine Rev1 WROOM modules
* 8x LEDs and 8x relays attached to an I2C GPIO extender.
* implementing soft PWM (fadeIn, On, FadeOut, Off) functionality in a dedicated task running at 1ms (i tick) intervals
* based on the specific timing and stage each bit is toggled on and off.
* DS2482-800 I2C to 1-Wire (8 channel ) bridge reading iButtons for access and resource control
* DS2482-800 is read every 1 sec (1000 ticks)
Originally I wrote each bit change (only changes) using an individual I2C write. Very quickly this crashed the I2C bus when all 16 actuators running. I then changed to buffer all bit changes for a full cycle of all 16 actuators, and then only write the full 16 bit-mapped GPIO states to the GPIO expander in a single 16 bit write.
This reduced I2C activity hugely, but I still on a completely irregular basis have the I2C bus freeze and the GPIOs/actuators go into random states.
My questions are as follows:
1) Have you had reasonable success with your simplified I2C driver?
2) If so, can you please share the latest version with me so I can try to port my actuator engine to run on your driver instead?
All feedback much appreciated,
Andre
Re: i2c randombly fails
I have the same problem, accidentally the esp32 transmission from MCP23017 hangs.
It stops working after some time - randomly. I have not found a solution still
It stops working after some time - randomly. I have not found a solution still
Re: i2c randombly fails
I am facing the same issue with I2C example provided in idf.
ESP32 Arduino works as expected whereas esp-idf gives the following errors
ESP-idf version: v3.1
Code:
ESP32 Arduino works as expected whereas esp-idf gives the following errors
- timeout : 0x107 (generated by I2C_STATUS_TIMEOUT)
- failed: -1 (generated by I2C_STATUS_ACK_ERROR)
ESP-idf version: v3.1
Code:
- #include <stdio.h>
- #include "driver/i2c.h"
- #define I2C_EXAMPLE_MASTER_SDA_IO 22 /*!< gpio number for I2C master data */
- #define I2C_EXAMPLE_MASTER_SCL_IO 23 /*!< gpio number for I2C master clock */
- #define I2C_EXAMPLE_MASTER_NUM I2C_NUM_0 /*!< I2C port number for master dev */
- #define I2C_EXAMPLE_MASTER_TX_BUF_DISABLE 0 /*!< I2C master do not need buffer */
- #define I2C_EXAMPLE_MASTER_RX_BUF_DISABLE 0 /*!< I2C master do not need buffer */
- #define I2C_EXAMPLE_MASTER_FREQ_HZ (10 * 1000) /*!< I2C master clock frequency */
- #define DATA_LENGTH 1 //18 /*!<Data buffer length for test buffer*/
- #define I2C_SLAVE_ADDR (8) /*!< slave address*/
- #define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */
- #define READ_BIT I2C_MASTER_READ /*!< I2C master read */
- #define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/
- #define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */
- #define ACK_VAL 0x0 /*!< I2C ack value */
- #define NACK_VAL 0x1 /*!< I2C nack value */
- static esp_err_t i2c_example_master_read_slave(i2c_port_t i2c_num, uint8_t *data_rd, size_t size)
- {
- esp_err_t err = ESP_OK;
- i2c_cmd_handle_t cmd = i2c_cmd_link_create();
- i2c_master_start(cmd);
- i2c_master_write_byte(cmd, (I2C_SLAVE_ADDR << 1) | READ_BIT, ACK_CHECK_EN);
- if (size > 1)
- {
- i2c_master_read(cmd, data_rd, size - 1, ACK_VAL);
- }
- i2c_master_read_byte(cmd, data_rd + size - 1, NACK_VAL);
- i2c_master_stop(cmd);
- err = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
- i2c_cmd_link_delete(cmd);
- return err;
- }
- static void i2c_example_master_init()
- {
- int i2c_master_port = I2C_EXAMPLE_MASTER_NUM;
- i2c_config_t conf;
- conf.mode = I2C_MODE_MASTER;
- conf.sda_io_num = I2C_EXAMPLE_MASTER_SDA_IO;
- conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
- conf.scl_io_num = I2C_EXAMPLE_MASTER_SCL_IO;
- conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
- conf.master.clk_speed = I2C_EXAMPLE_MASTER_FREQ_HZ;
- esp_err_t err = i2c_param_config(i2c_master_port, &conf);
- if (ESP_OK == err)
- {
- err = i2c_driver_install(i2c_master_port, conf.mode,
- I2C_EXAMPLE_MASTER_RX_BUF_DISABLE,
- I2C_EXAMPLE_MASTER_TX_BUF_DISABLE, 0);
- printf("i2c_driver_install 0x%x \n", err);
- }
- else
- {
- printf("i2c_param_config fail 0x%x \n", err);
- }
- }
- static void i2c_test_task(void *arg)
- {
- uint8_t data_rd[DATA_LENGTH] = {0};
- int cnt = 0;
- esp_err_t ret = 0;
- while (1)
- {
- printf("cnt: %d\n", cnt++);
- vTaskDelay(100 / portTICK_RATE_MS);
- ret = i2c_example_master_read_slave(I2C_EXAMPLE_MASTER_NUM, data_rd, DATA_LENGTH);
- if (ESP_OK == ret)
- {
- data_rd[DATA_LENGTH] = 0;
- printf("Data: %s \n", data_rd);
- }
- else
- {
- printf("err: 0x%x %s \n", ret, esp_err_to_name(ret));
- }
- }
- }
- void app_main()
- {
- i2c_example_master_init();
- xTaskCreate(i2c_test_task, "i2c_test_task_1", 1024 * 5, (void *)1, 10, NULL);
- }
Re: i2c randombly fails
Hi,
I had the same issues driving MCP23017 over i2c.
Hanging bus and getting randomly and not reproducible output to console:
After days of trying everything I found a solution that finally worked for me
Run the whole i2c and MCP23017 stuff in an own task.
Actually this code is running for some hours successfully without hanging bus or console outputs
Hope this will work for others, too.
PS: I'm using the latest Adafruit lib for MCP23017 @ 400kHz
https://www.arduinolibraries.info/libra ... no-library
I had the same issues driving MCP23017 over i2c.
Hanging bus and getting randomly and not reproducible output to console:
Code: Select all
esp32-hal-i2c.c:1378] i2cCheckLineState():Bus Invalid State, TwoWire() Can't init sda=1, scl=1
Run the whole i2c and MCP23017 stuff in an own task.
Code: Select all
void setup (void)
{
xTaskCreatePinnedToCore (mcpTask, "mcpTask", 2048, (void *)1, 1, NULL, CORE1);
}
void mcpTask (void *pvParameters)
{
while(1) {
delay(100); // calc. only every 100ms
static bool flgSetup = false;
if (!flgSetup)
{
configPinsMCP(); // wire.begin(..) + mcp.begin(..) + some setup stuff
flgSetup = true;
}
else
{
Inputs_100ms(); // cyclic task, switches MCP ports
}
}
}
Hope this will work for others, too.
PS: I'm using the latest Adafruit lib for MCP23017 @ 400kHz
https://www.arduinolibraries.info/libra ... no-library
Re: i2c randombly fails
Hi,
I am encountering the same issue and wanted to know if there was a fix.
When I do an SPI FLASH command while i2c is running, it causes an ESP_FAIL error on the i2c transaction. The scl pin is pulled low and then the sda pin as can be seen in the attached image. It does recover, but I wanted to know if there was a way to solve this issue?
I am encountering the same issue and wanted to know if there was a fix.
When I do an SPI FLASH command while i2c is running, it causes an ESP_FAIL error on the i2c transaction. The scl pin is pulled low and then the sda pin as can be seen in the attached image. It does recover, but I wanted to know if there was a way to solve this issue?
- Attachments
-
- i2cbug2.png (162.65 KiB) Viewed 10518 times
Who is online
Users browsing this forum: Bing [Bot] and 80 guests