Hi -- I have a DFRobot screen that has an ILI9488 and an SD card. I'm using TFT_eSPI to drive the screen and SdFat to read the SD card slot. Both seem to be working fine.
I'm a little fuzzy on the frequency issue... I read somewhere that the ILI9488 interfaces at 4MHz but I am overwhelmed at the technical docs for the chip so I can't confirm... at any rate, the TFT default setup that I'm using to configure the screen defaults to
#define SPI_FREQUENCY 27000000
...which would seem to be 27MHz? And if I set it to
#define SPI_FREQUENCY 80000000
...the screen still seems to work fine (although I'm not doing anything yet besides fillScreen()).
Read the documentation, I do not know what to look at as you did not tell what the mysterious processor is. The 4MHz is the maximum it will reliably work at, anything slower is probably better and less prone to problems. I suggest you read this first: SPI Tutorial – Serial Peripheral Interface Bus Protocol Basics
Thanks -- I didn't realize the MCU could be a bottleneck for the SPI speed. Module is ESP-WROOM-32 (on ESP32-DevKitC-VIE v4). Looks like that limits to 80MHz on the dedicated SPI pins?
I'm still a bit lost on how to find the max speed for the ILI9488 -- trial and error? Is it documented somewhere and I don't know what to search for? Same question for the SD card.
I'm currently looking through the esp32 docs to see if I can pull out the used frequency on the SPI bus to understand how the SD vs screen libraries are interacting... Looks like spi_device_get_actual_freq but I need to figure out how to pull out the device handle...
For a 16Mhz Uno it's clock/n, with a max of half the MCU clock (8Mhz), (defaults to 4Mhz).
So it can be 8, 4, 2, 1 etc. and the code downgrades to whatever nonsense you enter.
Don't know if the ESP behaves the same.
Leo..
spi_device_get_actual_freq isn't actually available in the IDE because it only came about in the latest ESP-IDF version. (I'm not sure I'd be able to get the SPI device handle required for it anyway.)
So I (think I?) figured out that you can do: spiClockDivToFrequency(spiGetClockDiv(SPI.bus()) (from SPI.h)
My screen is configured to run at 27MHz, but when I use the above code to print the bus frequency, it always says 80MHz, so I'm not sure if that's my mistake or a bug in TFT_eSPI. The screen works fine, though.
If instead of the screen I initialize and use the SD card reader over the same SPI bus, that code tells me that it is running at 16MHz, which is what it is configured to do, so that makes sense.
(The screen also works at 16MHz. The SD card reader only works at 16MHz (I only tried 27MHz and above though).)
So I'm confused about why the screen doesn't seem to set the bus frequency. But at least I think I'm making some progress.
I'm mainly just unsure if there is a "more adult" way to tell what frequency to drive these products at -- I'm not sure where it is documented, if in fact it is?
Thanks -- the only thing I considered might be an issue is that I'll be doing a lot of graphics updates to the screen and want them to not be sluggish, but even that won't really matter all that much in my particular application, I just wanted to know "what's the fastest it can be" so I can set it to that, but it seems like it's more nuanced a question than I expected.
Educated guess: The designer doesn't want the user to go higher than that.
If you leave it at 27mHz, then the MCU will use that, or a lower frequency the MCU is capable off.
Leo..
Yeah, the weird part is that when I leave it (the configuration) at 27MHz, the interface seems to be set to 80MHz... still working on figuring that out.
Update -- turns out the TFT_eSPI library uses its own internal SPI instance, so the default doesn't reflect the SPI freq correctly; if I pull that TFT SPI instance first and check frequency with it instead, it is in fact 27MHz (well, close to it). Then when the SD card initializes, the bus changes to 16MHz.
I'm still unclear as to when/whether it matters to devices if the bus changes frequency, given that it's within the max frequency that device can handle. Is SPI bus frequency changing no big deal, or can it confuse devices? Intuition says "no big deal" but any insight is welcome.