u8g2-hal-esp-idf icon indicating copy to clipboard operation
u8g2-hal-esp-idf copied to clipboard

u8g2_esp32_i2c_byte_cb u8g2_esp32_hal.c:179 (0 && "i2c_master_cmd_begin(I2C_MASTER_NUM, handle_i2c, I2C_TIMEOUT_MS / portTICK_RATE_MS)")

Open ghost opened this issue 2 years ago • 6 comments

Using your HAL code, I'm getting this error:

u8g2_esp32_i2c_byte_cb u8g2_esp32_hal.c:179 (0 && "i2c_master_cmd_begin(I2C_MASTER_NUM, handle_i2c, I2C_TIMEOUT_MS / portTICK_RATE_MS)")

I'm in the process of figuring out why, but opening an issue might be worthwhile.

ghost avatar Apr 25 '22 05:04 ghost

␛[0;32mI (558) u8g2_hal: sda_io_num 21␛[0m
␛[0;32mI (558) u8g2_hal: scl_io_num 22␛[0m
␛[0;32mI (558) u8g2_hal: clk_speed 50000␛[0m
␛[0;32mI (568) u8g2_hal: i2c_param_config 1␛[0m
␛[0;32mI (568) u8g2_hal: i2c_driver_install 1␛[0m
␛[0;31mE (878) err: esp_err_t = -1␛[0m

assert failed: u8g2_esp32_i2c_byte_cb u8g2_esp32_hal.c:179 (0 && "i2c_master_cmd_begin(I2C_MASTER_NUM, handle_i2c, I2C_TIMEOUT_MS / portTICK_RATE_MS)")

Backtrace:0x40082243:0x3ffdd040 0x40089e0d:0x3ffdd060 0x40090d39:0x3ffdd080 0x400d4dd6:0x3ffdd1a0 0x4013c09d:0x3ffdd1e0 0x400d5a03:0x3ffdd200 0x400d5991:0x3ffdd220 0x400d5cb5:0x3ffdd250 0x400d5dc4:0x3ffdd270 0x4013bcc9:0x3ffdd290 0x400d3e92:0x3ffdd2b0 0x400d49b4:0x3ffdd3a0 0x40140451:0x3ffdd560 0x4008d395:0x3ffdd580

ghost avatar Apr 25 '22 05:04 ghost

OLED is 128x64, board is Wemos/TTGO ESP32.

This I2C initialization works for me, but the library is painfully limited and I cannot put time into fixing someone else's shortcomings, just in case you see anything useful:

https://github.com/nopnop2002/esp-idf-ssd1306/blob/master/main/ssd1306_i2c.c

The HAL in this one is admittedly a bit ugly.

ghost avatar Apr 25 '22 05:04 ghost

According to the docs the error code -1 is returned when the client does not ACK the transfer. Since it works with another library, I assume that the problem lies somwhere in your I2C setup.

mkfrey avatar Apr 25 '22 07:04 mkfrey

TTGO LORA32 board, absolutely zero changes. I will check again but so far I came up with no explanations for this error. The linked I2C initialization code uses different frequency for master clock and timeouts and works perfectly.

ghost avatar Apr 25 '22 07:04 ghost

I have had the same issue. And the reason is because the I2C address is not passed correctly. The library is expecting the (address << 1) instead of the raw address.

r12f avatar Feb 13 '23 03:02 r12f