Page 1 of 1

[HELP!] ESP32 I2C Hardware or Bitbang?

Posted: Mon Mar 30, 2020 8:23 pm
by wperw1
Hi everyone, in theese days I'm trying to talk over i2c to a bno 055 produced by Bosch.
The problem in getting it work with ESP32 is that the bno 055 use clock-stretching that make ESP32 to go into timeout as i2c master also at 10kHz.
Checking the communication with Pulseview I've noticed that the clock stretching may be some times 1ms at 100kHz.
I've modified the file esp-idf/components/driver/i2c.c adding more clock pulses to the timeout modifing the I2C_MASTER_TOUT_CNUM_DEFAULT like this

Code: Select all

#define I2C_MASTER_TOUT_CNUM_DEFAULT   (8 * 8 * 2)
the added clock pulses partially solves the problem, but some times i2c continue to stop for timeout.

My problem is that if i2c fall into timeout just after sending the addres write the bno 055 goes to error, and I'vo to reconfigure the bno, losing a lot of precious time for my application.
Here a pic of the error from i2c side
i2c_bno_055_error.PNG
i2c_bno_055_error.PNG (58.53 KiB) Viewed 2737 times
So I've fall into a very "bad" idea, the idea is to try to make an i2c bitbang, before satrting with this huge and "ugly" idea (huge and ugly because C is a little dificult for me because I'm an OOP programmer with languages like VB.Net or C#), I'll like to knof if exsist some other "less" difficult alternatives.
Thank you so much!