Open bryghtlabs-richard opened 1 month ago
have you called esp_lcd_panel_io_rx_param
function with the io_read
handle in your apllication code or in your st7789bl driver?
Yes, I was calling esp_lcd_panel_io_rx_param
to read the display registers. If I use only one io handle at 6MHz, I can use esp_lcd_panel_io_tx_param
, esp_lcd_panel_io_rx_param
, and esp_lcd_panel_io_tx_color
. But when I create a second io handle, io_read
, and use esp_lcd_panel_io_rx_param
the SPI signals seem correct, but the chip-select does not toggle.
@bryghtlabs-richard I can reproduce the problem now. Thanks for reproting. The issue lies on, when SPI bus switches devices, it didn't update the connection between the SPI signal and the GPIO.
I'm glad you see it too @suda-morris.
Instead of having two SPI bus devices sharing one chip-select, would it make sense to add a function to adjust the SPI clock for a specific device? This would also avoid the additional memory usage from the second call to spi_bus_add_device().
@bryghtlabs-richard Hi ~
Yeah your idea is correct, but I think add API to adjust device's freq have other consideration:
BTW, device is abstract of a set of communication attribute for SPI bus, change device's attribute against this rule. and change frequency maybe not a common case, at least for now only some LCD and SD card. we can simply resolve issue in another way.
I can try to fix two devices issue and give you feedback, please waiting my good news :handshake:
I'm not sure if this would impact your design, but while working with ILI9481, I noticed it can benefit from adjusting SPI rate during transfer. Maybe ST7789 can too. But I think using spi-device per frequency, it would require starting transfer on one device, then switching device to finish transfer. Would that work? If the freq-switching is fast, it could save up to 40% of read-command bus-time, like this:
SPI driver can do a sync/async communication, when it work on async, it is hard for you to know freq switching point.
Yes, freq-switching point must be kept in the proper sequence for both sync/async transfers. One option might be to add it to spi_transaction_t, so freq-switching could be sequenced correctly for both.
I can try to fix two devices issue and give you feedback, please waiting my good news 🤝
Thank you for looking into this for us. 🤝
@bryghtlabs-richard
- Lower chip-select
- Send command-byte @ 40MHz
- Read data-byte @ 6.66MHz
- Raise chip-select
Yeah, by control CS pin manually, things goes simply, you can freely using different devices on different frequency.
the difficult point is to config different devices on same CS pin, then can control CS by hardware
Answers checklist.
IDF version.
v5.0.2 and beyond
Espressif SoC revision.
ESP32-S3
Operating System used.
Windows
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
CMD
Development Kit.
ESP32-S3-DEVKITC-1-N8R8
Power Supply used.
USB
What is the expected behavior?
I'm using an ST7789 SPI display. It supports writing pixels and registers over SPI at around 60MHz, but reading pixels and registers must be done below about 7MHz. The ESP-IDF spi_master and esp_lcd components each take only a single bus-speed. Sometimes I need to read registers, but I need my pixel transfers to occur at 40MHz to keep our animations smooth.
I tried ESP_Sprite's suggestion here: https://esp32.com/viewtopic.php?t=16704#p63258 , and I was able to create two
esp_lcd_panel_io_spi_config_t
with the same pins and different speeds and callesp_lcd_new_panel_io_spi()
to get twoesp_lcd_panel_io_handle_t
but only one seems to drive the chip-select line.Because there is no way to specify two different clock speeds, and because of ESP_Sprite's comment, I was assuming that two SPI devices on the same bus with the same chip-select would both be allowed to use the chip-select.
What is the actual behavior?
When two esp_lcd_panel_io_handle_t are created by esp_lcd_new_panel_io_spi using the same CS-pin, only one triggers the chip select.
Steps to reproduce.
Here is what I'm using for configs, and they both create a new panel-io without errors:
Debug Logs.