完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
(一)现象
我使用idf开发esp32c3,使用i2c外设时出现问题。I2C正常发送了出去,但从机没有应答。 我此前使用过nxp的lpc55s69进行过测试,并将这两次的波形使用逻辑分析仪采集出来,区别仅有ACK应答。读取数据的时候现象也是一样的,从机无法作出应答,但时序波形与lpc55s69下实验仅有ack部分有区别。 从机使用AS5600和ADXL345都测试过,现象如上一致。 引脚也更换过多个,包括4、5、6、8、9,都是如此。 实验使用的esp32c3为合宙版。后来又使用安可信的esp32(非c3),额外编写esp32工程,现象依然如此。 实验使用的idf为v4.4-release分支。开发环境ubuntu20.04+vscode+idf4.4 I use idf to program esp32c3, and problem occurred when using i2c. The i2c was send successfully as display in logic analyzer, but no ack receive from slaver. I had been test the slaver(both adxl345 and as5600) in NXP's lpc55s69, and it work as same as above, except the ack is successfully receive. I have change the pin of i2c, but it does not work! the board in this experience is esp32c3 developed by hezhou: the idf version is v4.4-release. and I develop it in ubuntu20.04+vscode+idf4.4 (二)代码 初始化 init 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 = I2C_MASTER_SDA_IO, .scl_io_num = I2C_MASTER_SCL_IO, .sda_pullup_en = GPIO_PULLUP_ENABLE, .scl_pullup_en = GPIO_PULLUP_ENABLE, .master.clk_speed = I2C_MASTER_FREQ_HZ }; i2c_param_config(i2c_master_port, &conf); return i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0); } 逻辑代码 the logic code 1-自己编写cmd-program by cmd // i2c_cmd_handle_t cmd = i2c_cmd_link_create(); // i2c_master_start(cmd); // i2c_master_write_byte(cmd, AS5600_I2C_ADDR << 1 | I2C_MASTER_WRITE, false); // i2c_master_write_byte(cmd, 0x00, false); // i2c_master_stop(cmd); // ret = i2c_master_cmd_begin(0, cmd, 1000 / portTICK_RATE_MS); // i2c_cmd_link_delete(cmd); // cmd = i2c_cmd_link_create(); // vTaskDelay(50 / portTICK_PERIOD_MS); // i2c_master_start(cmd); // i2c_master_write_byte(cmd, AS5600_I2C_ADDR << 1 | I2C_MASTER_READ, false); // i2c_master_read_byte(cmd, data, false); // i2c_master_stop(cmd); // ret = i2c_master_cmd_begin(0, cmd, 1000 / portTICK_RATE_MS); // i2c_cmd_link_delete(cmd); 2-调用函数-program by usb the sdk function i2c_master_write_to_device(I2C_NUM_0, 0x1D, data, 1, 500 / portTICK_PERIOD_MS); (三) 基于以上情况,我只能怀疑是不是sda电平在接收ack的时候被主机钳住总线了? 毕竟合宙的板子似乎外部没有接任何器件了,尽只有我挂的adxl345 而且安可信的esp32板子也是同样的情况,难道是有什么配置没有配好吗? I think the sda might be limited by esp32c3, thus the slaver can't pull it down? |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
406浏览 6评论
338浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
321浏览 5评论
322浏览 4评论
309浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-8-16 03:52 , Processed in 0.734125 second(s), Total 73, Slave 59 queries .
Powered by 电子发烧友网
© 2015 www.ws-dc.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号