Closed BasicGearwheel closed 1 week ago
Hello? Could you please check the function declaration esp_err_t i2c_master_transmit(i2c_master_dev_handle_t i2c_dev, const uint8_t *write_buffer, size_t write_size, int xfer_timeout_ms);
and find why?
@mythbuster5
Thank you.I had used the method in correct way before.But it still didn't work normally.The message from ESP32-S3 is actually the following text .Now the problem has been handled, because I have found that the GPIO which connect IIC devices are wrong.
E (50) i2c.master: I2C transaction unexpected nack detected E (50) i2c.master: s_i2c_synchronous_transaction(872): I2C transaction failed E (60) i2c.master: i2c_master_transmit(1074): I2C transaction failed ESP_ERROR_CHECK failed: esp_err_t 0x103 (ESP_ERR_INVALID_STATE) at 0x42008e01 0x42008e01: app_main at E:/Develop/Project/ESP-IDF/IIC/main/main.c:30 (discriminator 1)
file: "./main/main.c" line 30 func: app_main expression: i2c_master_transmit(mpu_handle, ac, sizeof(ac), -1)
abort() was called at PC 0x40379e47 on core 1 0x40379e47: _esp_error_check_failed at E:/Develop/Espressif/frameworks/esp-idf-v5.3.1/components/esp_system/esp_err.c:49
Backtrace: 0x403759ea:0x3fc98650 0x40379e51:0x3fc98670 0x40380705:0x3fc98690 0x40379e47:0x3fc98700 0x42008e01:0x3fc98730 0x4201a9e7:0x3fc98760 0x4037a941:0x3fc98790 0x403759ea: panic_abort at E:/Develop/Espressif/frameworks/esp-idf-v5.3.1/components/esp_system/panic.c:463 0x40379e51: esp_system_abort at E:/Develop/Espressif/frameworks/esp-idf-v5.3.1/components/esp_system/port/esp_system_chip.c:92 0x40380705: abort at E:/Develop/Espressif/frameworks/esp-idf-v5.3.1/components/newlib/abort.c:38 0x40379e47: _esp_error_check_failed at E:/Develop/Espressif/frameworks/esp-idf-v5.3.1/components/esp_system/esp_err.c:49 0x42008e01: app_main at E:/Develop/Project/ESP-IDF/IIC/main/main.c:30 (discriminator 1) 0x4201a9e7: main_task at E:/Develop/Espressif/frameworks/esp-idf-v5.3.1/components/freertos/app_startup.c:208 0x4037a941: vPortTaskWrapper at E:/Develop/Espressif/frameworks/esp-idf-v5.3.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
Answers checklist.
IDF version.
5.3.1
Espressif SoC revision.
ESP32-S3
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32 S3 WROOM- 1 DevKitC-1
Power Supply used.
USB
What is the expected behavior?
正常发送一个字符。
What is the actual behavior?
当我使用transmit方法时, 开发板报黄字并且重启。
Steps to reproduce.
include "driver/i2c_master.h"
include "driver/i2c_slave.h"
include "esp_log.h"
i2c_master_bus_config_t i2c_mst_config = { .clk_source = I2C_CLK_SRC_DEFAULT, .i2c_port = I2C_NUM_0, .scl_io_num = GPIO_NUM_10, .sda_io_num = GPIO_NUM_3, .glitch_ignore_cnt = 7, .flags.enable_internal_pullup = true, }; i2c_master_bus_handle_t bus_handle;
i2c_device_config_t mpu_cfg = { .dev_addr_length = I2C_ADDR_BIT_LEN_7, .device_address = 0x68, .scl_speed_hz = 100000, };
i2c_master_dev_handle_t mpu_handle;
uint8_t a = 0x80;
void app_main (void) { ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_mst_config, &bus_handle)); ESP_ERROR_CHECK(i2c_master_bus_add_device(bus_handle, &mpu_cfg, &mpu_handle)); ESP_ERROR_CHECK(i2c_master_transmit(mpu_handle, a, sizeof(a), -1)); }
Debug Logs.
More Information.
No response