-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32S3的SPI2_HOST使用spi_master外设时,用"spi_bus_add_device"添加大于三个从机时报错 (IDFGH-7288) #8876
Comments
用逻辑分析仪抓下cs线的电平看看?六个设备指的是三根cs线分别在高低电平的时候使能一个设备 |
@Huckies |
好消息是我找到一个折中的解决方法: gpio_set_pull_mode(BMP390_PIN_CS, GPIO_PULLUP_ONLY);
gpio_set_direction(BMP390_PIN_CS, GPIO_MODE_OUTPUT);
gpio_set_level(BMP390_PIN_CS, 1);
esp_err_t ret;
spi_device_interface_config_t devcfg={
.address_bits = 8,
.clock_speed_hz=BMP390_SPI_SPEED, //Clock out at 10 MHz
.mode=BMP390_SPI_MODE, //SPI mode (CPOL, CPHA)
.spics_io_num=/*BMP390_PIN_CS*/-1, //禁用CS pin
.queue_size=1, //We want to be able to queue 1 transactions at a time
.flags = /*SPI_DEVICE_3WIRE | */SPI_DEVICE_HALFDUPLEX,
.pre_cb = bmp390_pre_cb, //把CS置低
.post_cb = bmp390_post_cb, //把CS置高
};
//Attach the BMP390 to the SPI bus
ret=spi_bus_add_device(BMP390_SPI_HOST, &devcfg, &spi);
ESP_ERROR_CHECK(ret); 就是上面的配置,我把它理解为用软件片选代替硬件片选,就是把CS脚设置为-1(即禁用CS脚),然后把通信前调用的回调函数设置为把CS置低,通信后调用的回调函数设置为把CS置高,这样也能用。 |
@ou2356 你好,确实是官方忘记更改CS对应引脚信号的问题,很抱歉给你造成了困扰。目前S2,S3,C2,C3都有这个问题,并将在这个Issue关闭后得到解决,届时将可以使用6个引脚添加6个设备来使用。同时,感谢你的反馈。 |
好的,加油! |
@ou2356 这个问题在master上已经修复,你可以切换到master分支进行测试。如果你使用release版本,则还需要等待内部测试完成发布下一个小版本的时候才能使用。感谢! |
update gpio_sig at `spics_out` array in each spi_periph.c of chips later than s2 then `spi_bus_add_device` can correctly distribute gpio_signals for cs_signal Closes espressif#8876
update gpio_sig at `spics_out` array in each spi_periph.c of chips later than s2 then `spi_bus_add_device` can correctly distribute gpio_signals for cs_signal Closes #8876
update gpio_sig at `spics_out` array in each spi_periph.c of chips later than s2 then `spi_bus_add_device` can correctly distribute gpio_signals for cs_signal Closes #8876
update gpio_sig at `spics_out` array in each spi_periph.c of chips later than s2 then `spi_bus_add_device` can correctly distribute gpio_signals for cs_signal Closes #8876
你好, 我也遇到了类似问题。 |
@jinsonli 可以提供一下你使用的commit id吗, |
为了简化操作在ARDUINO 2.3.2内安装ESP32 V2.0.15测试运行SPI2外接6个SPI设备(需要6个CS端口)失败。 只能支持4个。查看ARDUINO下载的2.0.15库找到ESP32S3对应的soc_caps.h仍然显示限制数3. 查看最新版ESP-IDF V5.2.1中同一文件soc_caps.h确认已经修改为6,拷贝过去覆盖2.0.15库同文件,烧录无效。看来还有其他文件需要修改。 已经定制了上百片ESP32S3产品PCB,如短期内不能解决此问题只能全部报废换方案了。因为之前用的方案是METRO M4,主控是很老的SAMD21, 人家支持6个SPI毫无问题。 |
Environment
git describe --tags
to find it):// Release v4.4
xtensa-esp32-elf-gcc --version
to find it):// xtensa-esp32-elf-gcc (crosstool-NG esp-2021r2-patch2) 8.4.0
Problem Description
ESP32S3的SPI外设的SPI2在官方文档中说到最大支持6个设备,但是当我添加第4个设备时就出现了错误。
Expected behavior
4个SPI设备可以同时正常添加且使用。
Actual behavior
只能同时添加3个SPI设备(当我在4个SPI设备的添加中注释掉任何一个SPI设备的添加都可以正常运行)
Code to reproduce this issue
Debug Logs
Other items
然后我试图查找产生这个错误的原因:
1、触发"ESP_ERR_NO_MEM"错误的位置为:
esp-idf/components/driver/spi_master.c
Lines 338 to 340 in a82e6e6
2、间接原因位置:
esp-idf/components/driver/spi_bus_lock.c
Lines 558 to 581 in a82e6e6
esp-idf/components/driver/spi_common.c
Lines 812 to 816 in a82e6e6
3、我推测的根本原因位置:
esp-idf/components/soc/esp32s3/include/soc/soc_caps.h
Line 248 in a82e6e6
(这里的宏定义恒为3,与官方文档中说到最大支持6个设备不符合)
##后续的自我尝试
当我推测到这个根本原因位置后,把
esp-idf/components/soc/esp32s3/include/soc/soc_caps.h
Line 248 in a82e6e6
更改成
编译运行之后,虽然可以成功添加4个SPI设备,但是第四个添加的设备读取到的数据全是0xFF,估计就是通信失败。
The text was updated successfully, but these errors were encountered: