I put up a new Branch of my SPI Fork up at:
https://github.com/KurtE/SPI/tree/T4_FASTER
With this I changed the clock settings in begin:
Code:
hardware().clock_gate_register &= ~hardware().clock_gate_mask;
CCM_CBCMR = (CCM_CBCMR & ~(CCM_CBCMR_LPSPI_PODF_MASK | CCM_CBCMR_LPSPI_CLK_SEL_MASK)) |
CCM_CBCMR_LPSPI_PODF(2) | CCM_CBCMR_LPSPI_CLK_SEL(1); // pg 714
// CCM_CBCMR_LPSPI_PODF(6) | CCM_CBCMR_LPSPI_CLK_SEL(2); // pg 714
So now using the Clock selection option 1 with PODF 2 instead of 6:
Now translated into English:
Before Clock Select 2 was choosing PLL2 which is 528mhz
Now choosing option 1 which is PLL3 PFD0 whch is 720mhz.
Then the PODF (is a divisor of this value plus 1:
So clock going into lpspi was 528/7 = 75.42mhz
Now the clock is: 720/3: = 240mhz (I thought about passing in 5 which would be 120mhz...
Now the actual clock speed is even divide of the passed in clock with minimum of 2 (actually value in register is divide-2).
So before max SPI speed was about 37.7mhz...
With the above the max is 120mhz... I have not tried 120... Probably will screw up. I did try 60mhz and found that there may be issue with going that fast with how the IO pins were configured...
So I have tried changing the pin configuration from:
uint32_t fastio = IOMUXC_PAD_DSE(7) | IOMUXC_PAD_SPEED(2);
//uint32_t fastio = IOMUXC_PAD_DSE(6) | IOMUXC_PAD_SPEED(1);
That is I think it drives the pins with more Drive strength and I think says should work for higher speeds.
And I have done a couple of tests that appear to work.
Example with our ili9488_t3 library (current stuff with 16 bit frame buffer on T4) and running at the default SPI speed, the speed test gave me times of:
Code:
ILI9488_t3n: (T4) SPI automatically selected
MOSI:11 MISO:12 SCK:13
ILI9488 Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark Time (microseconds)
Screen fill 615176
Text 11924
Lines 151482
Horiz/Vert Lines 50646
Rectangles (outline) 28136
Rectangles (filled) 1486768
Circles (filled) 178811
Circles (outline) 121726
Triangles (outline) 32838
Triangles (filled) 456314
Rounded rects (outline) 54180
Rounded rects (filled) 1618679
Done!
I then used the optional parameter on our begin method to pass in requested SPI speed of 60mhz and the times are now:
Code:
ILI9488_t3n: (T4) SPI automatically selected
MOSI:11 MISO:12 SCK:13
ILI9488 Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark Time (microseconds)
Screen fill 307987
Text 7466
Lines 92690
Horiz/Vert Lines 25840
Rectangles (outline) 14425
Rectangles (filled) 744867
Circles (filled) 99820
Circles (outline) 79335
Triangles (outline) 19801
Triangles (filled) 235967
Rounded rects (outline) 32342
Rounded rects (filled) 817098
Done!
It would be great of others could test these changes out and if they work OK, I will issue a Pull Request back to @PaulStoffregen...