Ideas for improving LCD speed

I can answer my own question after reading spi_set_baudrate() in the pico-sdk.

SPI clock must be an even subdivision of another clock. At the default main clock of 125 MHz, the even subdivision is 62.5 MHz, as I got.

The trick I found while reading is when I called set_sys_clk_khz() the SPI clock then defaults to referencing a different 48 MHz clock, and thus the even subdivision is the 24 MHz I saw.

However you can request to use the system clock by adding this line into CMakeLists.txt:

add_compile_definitions(PICO_CLOCK_AJDUST_PERI_CLOCK_WITH_SYS_CLOCK=1)

It is not clear to me if changing this setting might mess up other peripherals, but my program runs OK.

With that in place I can ask for a 150 Mhz system clock and get a 75 MHz SPI clock and get close to 30 fps. Asking for 200 MHz and 100 MHz works, and I get ~40 fps.

2 Likes

This is great work Geoff!

one caveat about changing peripheral clock, watch out for it affecting the SD card as well, which is also SPI

unless you change it during runtime it’s unlikely you’ll run into an issue, but, it’s good to keep in mind in case something crops up

1 Like

I wondered if the repeated drawing was hiding any screen tearing, so I tried the 200 MHz / 100 MHz in Mandelbrot since it only writes once and there were no artifacts. Seems like my LCD can handle 100 MHz writes.

Thanks @maple. I wondered what else was on SPI. My programs don’t use the SD card so far, but I can see a use coming up. I will watch for any effects and report what I see.