Open bdlabitt opened 4 years ago
Sorry, last line should read, "SPI clock is 24MHz, not 33MHz". SPI clock is not being set to TFT_FREQ.
I'm noticing similar behavior on a Particle Boron. Might be unrelated but seems like the same issue.
I'm beginning to believe this is posted in the wrong place. If so, where should it go? ILI9341? No review or comment in over 6 months. Not even an acknowledgement of the issue. From what I can determine, proper DMA SPI management is non-trivial. Furthermore the solution appears to need to be compatible with SPI., SERCOM., startup.c, Adafruit_SPIDevice., and perhaps Adafruit_ZeroDMA.
For my application, I am not using the SD card on the TFT board. So it would be preferable to have a solution with SPI at 40-48MHz for write, and perhaps 24MHz for read for an M4 Express. By 40-48MHz it is meant a single fixed frequency somewhere around this value.
i was wondering about overclocking SPI speed too. i found this SPI speed related info on here : https://learn.adafruit.com/adafruit-feather-m4-express-atsamd51?view=all Look for "Max SPI and Max QSPI" in the article. this is exactly what you are looking for but it seems like adafruit removed the Max SPI option in Arduino, theres only a setting for MAX QSPI.
Appears my comment was deleted. Not sure if I crossed a line. Apologize if I did. Wasn't intentional bashing.
Disappointing there is no apparent solution to this issue after 26 months. A lack of solution is ok, but some sort of explanation why this is difficult or impossible, would be greatly appreciated.
The SPI clock rate setting at high clock rates on the SAMD chips goes by big jumps at high frequencies, because it's a small divisor value.. You may need to try 48MHz instead of 24. See for instance https://github.com/adafruit/circuitpython/issues/464#issuecomment-347676877 and https://github.com/adafruit/circuitpython/pull/560 That discuss SAMD21 more than SAMD51, but the same problem is present.
@dhalbert Thank you for a clue! Haven't jumped to the URLs yet, but notionally how does one change the clock? More specifically, which clock? Going off to read...
Some good discussion in the other threads. Unfortunately, not being as skilled in the art as many are, it is unclear what to set and where to set it. A few breadcrumbs would be appreciated. Thanks!
I mean that to get a higher SPI frequency than 24MHz, you may need to specify 48MHz, not just 32 or 33MHz. Anything in between will just take the nearest lower possible frequency. 32MHz or 33MHz is probably not possible.
It is worth a try! Not sure the display can manage it, but it is worth trying. So just tft.begin(48000000) ? Hope to try this today.
yes, try that, or even higher, but you have to change the Arduino menu items, as mentioned, and we don't guarantee it will work. I think 48MHz may be the max.
"but you have to change the Arduino menu items" I don't understand this. Which Arduino menu items and where are they found? I don't recall seeing any menu items related to SPI. At this point I'm running 1.8.19 IDE.
Aha, I think the Board Support Package originally had a menu item to adjust the max SPI speed, and that was documented in the guide. However, we took that option away: https://github.com/adafruit/ArduinoCore-samd/pull/110. Instead you can set the clock source, using SPIClass::setClockSource()
. The possible values are here.
The default clock source is the 48MHz clock, I think. Try 48MHz for now, without changing the clock source. If that doesn't work (24 MHz might be the max for a 48MHz clock), you can try changing the clock source to the CPU frequency (120 MHz) or the 100 MHz clock), so you can get higher frequencies.
Yes. The board support package did offer this - but only for a short while! I remember using it, and then it vanished from the IDE. Thanks for some ideas to try! I will try a couple things and get back to you. Think I will be able to do this this weekend.
Hmm, more difficult than I thought. I don't know which instantiation of SPI to set the clock or baudrate. Is this exposed through the Adafruit_ILI9341 interface? How would I know what the handle is? Could you provide a minimum example that might do this? tft is the module that calls SPI, not me. I did try tft.begin(48000000); That doesn't do anything, nor does 48000001. Still 24MHz. Do I make a #define in Adafruit_ILI9341.cpp for SAMD51 for SPI_DEFAULT_FREQ?
Or is this deep in the SPI library that I have to make this change? Just confused about where the change goes, and how to get the correct instance. Don't want to have to permanently maintain the spi lib for a single project, if I don't have to.
Any additional ideas or leads would be helpful. Thanks.
begin, sends a command initSPI, but it only sends frequency, not the clock source. begin also has access to setSPISpeed via Adafruit_SPITFT.h. But there doesn't seem to be a way to pass this through to SPI itself. SPI seems to over-ride the setting.
I have tried define MAX_SPI 48000000 prior to including SPI.h and Adafruit_ILI9341.h. But I don't see a way (my lack of knowledge) to setClockSource for the tft instance of SPI. The version of SPI.cpp is found in .arduino15/packages/adafruit/hardware/samd/1.7.10/libraries/SPI
Also tried a `#define MAX_SPI 48000000
prior to including SPI.h and Adafruit_GFX.h and Adafruit_ILI9341.h and Adafruit_FT6206.h in my header file. Still 24MHz.
For what it is worth, the PJRC lib ILI9341_t3n supports a 30MHz write rate and a 20MHz read. That would be pretty nice if something like that worked on a Feather M4. Unfortunately the PJRC lib is not compatible with Adafruit's. The incompatibility seems to be in the dma section, or that's where the compiler starts complaining!
Maybe related to https://github.com/arduino/ArduinoCore-samd/issues/680? Nevertheless, speeding up the clock doesn't help as much, since the begin_transaction/end_transaction macros slow things down.
Added two lines of code to graphicstest.
Put oscilloscope probe on SPICLK at the ILI9341 display. Full code below.
CPU Speed 120 MHz -Os debug off
Also does not generate correct clock for other higher speed cpu clocks, or higher level of optimization. Expect SPICLK to be set to TFT_FREQ. Documentation states this will happen.