I'm using an Arduino Due that talks via SPI to an LCD (800x480) with the RA8875 controller chip. The most recent datasheet I could find is: RA8875 datasheet. Everything works as expected when using the Adafruit library. But, for my project, I want to maximize the communication speed between the LCD and the Arduino DUE.

Page 60 of the datasheet tells me that the maximum SPI speed to perform a SPIread is

system clock / 6.

Page 39 gives the formula for the system clock:

SYS_CLK = FIN * ( PLLDIVN [4:0] +1 ) / (( PLLDIVM+1 ) * ( 2^PLLDIVK [2:0] ))

There are some constraints:

  1. From page 39:
    FPLL = FIN * ( PLLDIVN [4:0] +1 ) must be equal to or greater than 110 MHz

  2. From page 91:
    For an LCD of dim 800x480 2 layers 8bit color depth 60Hz framerate the pixel clock should be between 30 and 33MHz. (Registers are set to have 2 layers and 8 bit color depth).

A crystal of 20Mhz is soldered on the LCD ( FIN = 20 Mhz)

I have set the registers as follows:

Register Value
PLLC1[88h] 24
PLLC1[89h] 1
PCSR[04h] 3

So, I expect:

  • SYS_CLK = 20 Mhz * ( 24 +1 ) / (( 0+1 ) * ( 2^1 )) = 250 Mhz
  • Pixel clock = SYS_CLK / ( 2^3 ) = 31.25 Mhz
  • Max. spi speed = 250 Mhz / 6 = 41.66 Mhz.

I think to obey every given constraint. But when I use an spi-speed of 30 Mhz, which is below 41.66 Mhz, I get a black screen.

I've put the Arduino sketch and the modified Adafruit library (Sven_RA8875) on google drive: Arduino sketch + modified library.

The same data but on a pastebin:

Image: Working LCD at 20 Mhz

Example code RA8875

Modified library .cpp

Modified library .h

Edit by PPK: I add the pictures from paste pics to this post after I scaled and croped them.

Osci display with 20 MHz setup

Osci display with 30 MHz setup Osci display with 30 MHz setup

  • You computed the max speed of the display, but what about the Due. Can it handle 30 MHz SPI speed? Source from the internet claim that more than 20 MHz is not possible. Another thought: Even if the Due manages the 30 MHz, the endpoints need a fairly good shaped clock signal. If you use unshielded wires to connect the devices, that could disturb the signal form and makes the communication unreliable. I fear you need an osci the check that. And, does the display uses PWM to dim the backlights of the LCD? Then, did you configured the PWM signal bright enough? – Peter Paul Kiefer Feb 9 at 9:28
  • Thanks @PeterPaulKiefer for your ideas! The Due seems to be able to have an spispeed of 84Mhz (arduino.cc/en/Reference/SPISetClockDivider). I attached a scope to the SPI clock signal once with and once without my changes for the spispeed. I've added them to the Google drive link above. The 30 Mhz spi clock seems okay. For the backlight, that is indeed pwm and it is bright enough (I dont change it between the example code and the modified code) – user72330 Feb 9 at 13:05
  • 1
    Sorry, I have no access to google drive and prefer not to log in. It would be better if you add the code and pictures direct to the question, in order to keep it if your google account would be deleted. --- The function you use is deprecated. --- Even if you set the clock speed to 84MHz, the send register must be filled with the picture data. That normally involves index computation and so on. After 8 Cycles the send register is empty, can you fill it within 8 CPU cycles? Or do you use DMA? I have some more ideas, but I'm busy at the moment. I'll come back. – Peter Paul Kiefer Feb 9 at 13:55
  • I have added the code and images using pastebin links so no account is required. I tried to attach them directly but the size is to big. Okay it makes sense that I have actually a 30 Mhz clock but the data doesnt have enough time to load into the registers. I am not using DMA. Thanks for this, I did not think about it! – user72330 Feb 10 at 10:00
  • When I saw the pictures, my first thought was: The 30 MHz signal is useless. The slope is not steep enough. But then I saw the blue wires (soldered?) to the board. Do you use them to connect the probes of the osci? That's not a good idea, as this long wires disturb reshape the signal at these frequencies; the wire acts as a low pass filter. – Peter Paul Kiefer Feb 10 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.