ESP32s3 I2c0 SCL一直高电平,没有时钟输出,SDA也是一直高电平
日志显示初始化成功
I (4197) driver-codec: i2s driver init success
I (9197) driver-codec: I2C_MASTER_NUM=0,mode=1,speed=100000
I (9197) driver-codec: I2C initialized successfully
I (9207) driver-codec: i2c_read cnt = 0, error = -1
代码如下:
#define I2C0_MASTER_SCL_IO 18 /*!< GPIO number used for I2C master clock */
#define I2C0_MASTER_SDA_IO 17 /*!< GPIO number used for I2C master data */
static esp_err_t i2c_master_init(void)
{
int i2c_master_port = I2C_MASTER_NUM;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C0_MASTER_SDA_IO,
.scl_io_num = I2C0_MASTER_SCL_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
.clk_flags = 0,
};
esp_err_t err = i2c_param_config(i2c_master_port, &conf);
if (err != ESP_OK) {
return err;
}
ESP_LOGI(TAG, "I2C_MASTER_NUM=%d,mode=%d,speed=%d",i2c_master_port,conf.mode,conf.master.clk_speed);
return i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
}
uint16_t AW88266A_i2c_read(unsigned char reg_addr)
{
int ret;
uint8_t cnt = 0;
uint8_t data_buff[2] = {0};
uint16_t data = 0;
while (cnt < I2C_RETRY_TIMES)
{
ret = i2c_master_write_read_device(I2C_MASTER_NUM, AW88266A_CODEC_ADDR, ®_addr, 1, data_buff, 2, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS);
if (ret != 0)
ESP_LOGI(TAG, "i2c_read cnt = %d, error = %d\n", cnt, ret);
else
break;
cnt++;
}
data = (((data_buff[0] << 8) & 0xff00) | (data_buff[1] & 0x00ff));
ESP_LOGI(TAG, "i2c_read data = %d\n", data);
return data;
}
ESP32s3 I2c0 SCL一直高电平,没有时钟输出
Jump to
- English Forum
- Explore
- News
- General Discussion
- FAQ
- Documentation
- Documentation
- Sample Code
- Discussion Forum
- Hardware
- ESP-IDF
- ESP-BOX
- ESP-ADF
- ESP-MDF
- ESP-WHO
- ESP-SkaiNet
- ESP32 Arduino
- IDEs for ESP-IDF
- ESP-AT
- ESP IoT Solution
- ESP RainMaker
- Rust
- ESP8266
- Report Bugs
- Showcase
- Chinese Forum 中文社区
- 活动区
- 乐鑫活动专区
- 讨论区
- 全国大学生物联网设计竞赛乐鑫答疑专区
- ESP-IDF 中文讨论版
- 《ESP32-C3 物联网工程开发实战》书籍讨论版
- 中文文档讨论版
- ESP-AT 中文讨论版
- ESP-BOX 中文讨论版
- ESP IoT Solution 中文讨论版
- ESP-ADF 中文讨论版
- ESP Mesh 中文讨论版
- ESP Cloud 中文讨论版
- ESP-WHO 中文讨论版
- ESP-SkaiNet 中文讨论版
- ESP 生产支持讨论版
- 硬件问题讨论
- 项目展示
Who is online
Users browsing this forum: No registered users and 101 guests
- All times are UTC
- Top
- Delete cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. ESP8266EX and ESP32 are some of our products.