Hi, I’m working on my tiny LCD for the AE3 camera.
Is there a way to adjust SPI clock speed for the SPIDisplay class?
I got it kinda running (not yet perfectly configured) by manual SPI transfer, but I see it fails if the clock speed gets too high, I’d like to rule this out as an issue, but I cannot find info on how fast the SPIDisplay class is driving the SPI interface nor a way to set the baudrate there…
thanks in advance!
Hi, it’s controlled by the fresh rate and resolution you set. So, just lower the refresh rate. The clock is nominally the resolution * bits per per * refresh rate.
This also explains, why my previous attempts started failing at some specific resolution… the clock rate crossed the maximum… 
So, my LCD back door the AE3 works… Kinda.
If works up to 23fps, above that the clock is too fast for something. Maybe for my level shifter, maybe for the TFT panel, maybe for the level shifter on the LCD board. There’s also tearing when there’s some rapid motion, but that’s to be expected given no sync and relatively slow clock.
I have plans to add TE pin support to the driver, as our new larger LCD shield supports that. However, not a priority right now. But, run a connection from the TE pin on the display to the MCU. This can be used to fix the tearing in the future.
Also, I would crop the output such that you use the whole display.
This small LCD does not have the TE pin connected at all, so I have no choice there.
I display the picture pixel:pixel without scaling, right as picked from the sensor, the sides are cropped by 20 pixels each side, the top and bottom are letterboxed because the LCD is 240 pixel tall and the camera runs at 320x200. It might be that in the photo it was either scaled down more or cropped more, hence the bars are wider.
I have r/n stable 18fps when running some blob recognition and serial comms in the loop, the limiting factor is the clock rate of the LCD - I have it set to 20fps at 280x240.
If I cut down the display area to 280x200 I can have 25fps in the LCD config, resulting in close to 20fps total framerate. I can live with that, even if I’d really love not to be limited by the clock frequency 
So it seems, that the NXS0104BQX, which I ‘stole’ from the AE3 OLED breakout board, is the limiting factor… it has f_max of 24MHz and that is pretty close to where I lose the display:
23fps => 23×240×280×2×8 = 24.72MHz - still works
24fps => 24×240×280×2×8 = 25.8MHz - no longer works
For the smaller 128x128px display it is sufficient (24MHz <=> 90fps), I just didn’t check…
Well, time for the next prototype 
There’s one of those on the AE3 on P0-P3. So, you cannot avoid its limits. There’s another on P4-P5. Only P6-P7 have no level shifter. But then there’s no SPI bus.
I would be happy with 24 MHz or so. Going beyond that starts to get challenging with external I/O pins in general.
Note, we don’t support DMA mode with the AE3 on SPI yet. If that were enabled then the display update would happen without any CPU impact and you could run way faster. That’s where a lot more speed could be unlocked.
We have that working on the IMXRT and STM32 - full triple buffered mode with DMA offload. However, the AE3 has a very complex DMA system. If you want to try to get it working with Claude, go ahead.
You are right… I blanked there. No point in making the slow signals faster if the actual SPI interface is speed-limited. On top of that I just figured out, that I’m actually overclocking the ST7789 chip already, as it is specced only up to 16MHz SPI clock. However, people reported running it at even as high, as 80MHz without much issues, so I think the level shifter is the actual bottleneck right now. Can’t change that though, it’s on the AE3 itself, like you rightly pointed out.
Anyway, I have to run another iteration of my PCB anyway, as the way it is built right now I need to remove the back of the AE3 case to plug it in. But I no longer see it as high priority.
If I have a spare minute I will look into the DMA stuff for the SPI, but I do not have paid Claude access and so I will dig old-fashioned, manually, with a bit shovel 