How to work with multiple I2C RTOS tasks?

MikeLemon
Posts: 45
Joined: Tue Feb 02, 2021 5:55 pm

How to work with multiple I2C RTOS tasks?

Postby MikeLemon » Thu Feb 11, 2021 5:08 pm

Hi
I'm quite new to the whole make based programming and IDF migrating from the arduino world so,

I'm trying to drive an I2C display using the u8g2_hal library and ss1306 display with an I2C ADC in two separate tasks and it seems like after both tasks start the ESP32 crashed with this error log:

Code: Select all

E (510) i2cdev: Could not read from device [0x48 at 0]: 263
E (510) ads111x: Could not read from register 0x01
I assume it's because the I2C display task tryes to use the bus while the adcRead task reads from it I've tries setting the I2C time out with :

Code: Select all

    i2c_set_timeout(I2C_NUM_0, 100000 / portTICK_RATE_MS);
no luck there and I can't find any function that checks if the I2C bus is being used so how can this be dealt with?

allard
Posts: 5
Joined: Fri Dec 20, 2019 11:01 am

Re: How to work with multiple I2C RTOS tasks?

Postby allard » Fri Feb 12, 2021 12:06 pm


MikeLemon
Posts: 45
Joined: Tue Feb 02, 2021 5:55 pm

Re: How to work with multiple I2C RTOS tasks?

Postby MikeLemon » Sun Feb 14, 2021 2:12 pm

I am using a binary mutex for the job but the I2C command probably works like shot and forget in the ESP32 meaning if I do u8g2_SendBuffer(&u8g2);

which updates the I2C display's buffer it still crashed before as after xSemaphoreGive(mutexBus); while updating the display it still uses the I2C for the display and runs it over with the I2C DAC communication.

Who is online

Users browsing this forum: Google [Bot] and 256 guests