RA8875 Graphics Board - speed bottleneck

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
bostonkiwi
 
Posts: 7
Joined: Wed Jan 22, 2014 2:47 pm

RA8875 Graphics Board - speed bottleneck

Post by bostonkiwi »

I am building a real-time spectral display (for SDR radio) using a Due, the RA8875 driver board (#1590), and the 5inch TFT display (#1680).
Everything works great - the display looks great - BUT with one exception: the RA8875 is very slow.

Here's the situation: my math (windowing, 256 point complex 16-bit FFT, log-magnitude, reordering, scaling, averaging) takes just over 3 msec on the Due. Then to update the simple display via the RA8875 takes 166 msec! This simply involves drawing two 256 segment lines (the first to overwrite the old line, the second to display the new result). Thus I'm limited by the graphics board to a refresh rate of about 6 fps, which is marginal at best for a dynamic display.

I have timed the call to tft.drawline() (draw one line segment) on the Due at 306 usecs, which seems to be very slow for a hardware accelerated graphics board. If you multiply 306 x 512 you get my refresh rate.

My question is whether the slow speed is due to the SPI interface, or is inherent in the RA8875 chip? I have been looking through the Adafruit library and the RA8875 data sheet for possible speed-ups. I'm writing a tft.drawgraph() to draw all segments in one call, but I think the improvement will be marginal at best.

BTW - I was disappointed to see that a lot of the RA8875 functionality is available only through its parallel MCU interface, and not through SPI.

Derek

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by pkourany »

I considered buying a display from buydisplay.com that has an R8875 controller built-in. Your comments tweaked my interest. I looked at Adafruit's library and noticed that they use DIV128 for their SPI clock divider. I suspect that value can be dropped depending on your MCU board and may be the cause of your "slow" display. You can try and modify the Adafruit_RA8875.cpp file, line 76:

Code: Select all

 SPI.setClockDivider(SPI_CLOCK_DIV128);  --> Change DIV128 to DIV64, DIV32 or DIV16 to see if things speed up
I was surprised when you wrote: "BTW - I was disappointed to see that a lot of the RA8875 functionality is available only through its parallel MCU interface, and not through SPI."

The R8875 documentation (which is outdated on Adafruit's link) clearly indicates that all functions are available via the different interfaces. The Adafruit library only supports some of those functions but you can easily extend the code to support whatever functions you want. You have access to all RA8875 registers and commands.

:D

User avatar
bostonkiwi
 
Posts: 7
Joined: Wed Jan 22, 2014 2:47 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by bostonkiwi »

Thanks for your reply, I'll certainly try it tonight.

In looking at the Adafruit library (and the data sheet), each call to tft.drawLine() takes 24 SPI byte transfers to the RA8875. Each low level command (writeData() and writeCommand()) uses a digitalWrite() to the CS pin to toggle CS low and back to high. Since there is only one SPI device I will try setting pin 10 (CS) low permanently and taking the digitalWrite()s out of the library calls. On a Due it shouldn't make that much difference however.

My comment re the parallel MCU interface was provoked by Section 7.6 on page 123 of the data sheet about the Block Transfer Engine (BTE)... where it says, if I understand it correctly, that moving blocks of data is available only on parallel interfaces.

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by pkourany »

I missed that! You are correct regarding the BTE. It seems they don't have a data path from the I2C/SPI interface h/w to their onboard DDRAM. Odd but not surprising. Kinda takes the wind out of what would otherwise be a great controller. :shock:

User avatar
bostonkiwi
 
Posts: 7
Joined: Wed Jan 22, 2014 2:47 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by bostonkiwi »

Just another thing for me to try tonight - I'll mod the library to take the color argument out of drawLine(), which will save 6 of the 24 SPI transfers, and add a setGraphicsColor() function. Then I also wonder if I really must wait for the draw command to complete with the waitPoll() before loading the next segment, in other words is there a FIFO buffer on the SPI interface.

User avatar
pkourany
 
Posts: 51
Joined: Wed Nov 27, 2013 12:57 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by pkourany »

I was just looking at the 4-wire demo code (http://www.buydisplay.com/download/demo ... moCode.txt) in the buydisplay.com site for the 4.3" RA8875 display unit. Starting at line 1126 of the file, there are three BLE demos!!! This file is clearly for the 4-wire SPI mode so WTF! It may be worth doing a test based on the demo code.

:!:

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by adafruit_support_mike »

The SPI interface in the existing library is a minimal working interface that won't scare beginners too much, and also a layer of defensive coding WRT people who have a bit more experience. Parallel interfaces consume lots of pins and programming resources, but people don't seem to grok that until they've had to deal with the details personally.

WRT the speed of the SPI interface, the Due's SPI clock is set to 4MHz, but you can change that with 'SPI.setClockDivider()'. The RA8875's internal clock speed is 30MHz, and the pixel clock seems to run from 20MHz to 60MHz. I'd imagine you cnan bump up the speed a few notches.

User avatar
bostonkiwi
 
Posts: 7
Joined: Wed Jan 22, 2014 2:47 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by bostonkiwi »

Well.... after spending a night twiddling with the library I've decided to move on :(

Here's what I found:
1) There's a moderate (not huge) improvement by taking the line color out of the call to drawLine().
2) Setting the CS line permanently low - I couldn't get it to work.
3) Deleting the call to waitPoll() in drawLine() is not a good idea - you end up with random lines missing.
I timed the polling wait time - it's 25 usec, which is not huge.
4) If you look at the library initialization, you will see that about 10 lines down from where the SPI clock
divider is set to SPI_CLOCK_DIV128, it is set again to SPI_CLOCK_DIV4 - so there's not much to be
gained there. I tried SPI_CLOCK_DIV2 but it seemed to make no difference.

I can double the refresh rate by using a filled rectangle to overwrite the previous line, but that makes the display flash - especially on the right hand side of the screen.

Having written a few complete graphics packages, I feel the primitives in the RA8875 leave quite a bit to be desired. For example, given the communication bottleneck it would be great if it had the concept of its current x-y position so that there could be function drawTo(x,y) with much reduced SPI transfers, and even better drawDelta(deltaX, deltaY) for single byte incremental coordinate transfers. And how about multi-segment lines, polygons, splines, Beziers etc?

On to bigger and better things,
Thanks,
Derek

User avatar
tomek
 
Posts: 73
Joined: Wed Jun 13, 2012 1:37 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by tomek »

It might be a bad idea for me to resurrect this rather than ask a new thread, but I have a silly question I hoped might be clear to someone else.

Where there is "SPI_CLOCK_DIV4" I received a 30%ish speed increase by changing it to DIV2.

Is there such a thing as DIV1? I cannot find where "SPI_CLOCK_DIV"s are defined.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by adafruit_support_mike »

The clock division macros are defined in SPI.h, among the standard libraries.

The division only goes down to 2. The SPI hardware has to shift the data register between ticks of the SPI clock, so the fastest possible rate is one SPI tick for every two ticks of the system clock.

User avatar
tomek
 
Posts: 73
Joined: Wed Jun 13, 2012 1:37 pm

Re: RA8875 Graphics Board - speed bottleneck

Post by tomek »

Ah! thanks :). Good to know a bit more.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”