A question of speeeeeed

Hi guys,

I am using this RA8875 Driver Board for 40-pin TFT Touch Displays - 800x480 Max : ID 1590 : $39.95 : Adafruit Industries, Unique & fun DIY electronics and kits to draw to a 5 inch screen with my Arduino uno. The problem is that if I want to draw pictures I have to do this one pixel at the time.

I tested this by using a for loop and drawing 1 black pixel at a time, but it takes a LONG time. I didn't time it but I think like 30 seconds.

Can anyone recommend a way of increasing the speed of this? I know that the TFT driver is capable of super fast drawing and that it is my end which is slowing things down.

I was thinking of buying the Arduino Due, but not sure if it this would even be up for the task!

PS. The interface is SPI.

There is a link in the description to this library - GitHub - adafruit/Adafruit_RA8875: Adafruit Arduino library driver for the RA8875 TFT driver -

Should get you started...

Here is an idea. Do not use the arduino's spi library for the arduino uno. Instead use this simpler and faster code. You can replace the spi calls they use in the library with these.
To initialize spi simply do

//enable spi
SPCR=80;//spi enable master
SPSR=1;//double speed

To write a byte do

static inline void spiWrB(unsigned char dat){
	SPDR = dat;
	while(!(SPSR & (1<<SPIF)));// Wait for transmission complete
}

To read a byte do

static inline unsigned char spiRdB(void){
	SPDR=0;//send dummy value to get byte back
	while(!(SPSR & (1<<SPIF)));
	return SPDR;
}

You will have to manually control the CS pin including setting it as output. It does not matter which pin you use.

cameronasmith:
I am using this RA8875 Driver Board for 40-pin TFT Touch Displays - 800x480 Max : ID 1590 : Adafruit Industries, Unique & fun DIY electronics and kits to draw to a 5 inch screen with my Arduino uno. The problem is that if I want to draw pictures I have to do this one pixel at the time.

Unfortunately, it looks like a -big- chunk of functionality for that driver chip is missing from the Adafruit breakout board for the RA8875 - namely the "Block Transfer Engine (BTE) Function" (see page 123 of the datasheet). It notes that the BTE function is only available with the "Parallel MCU Interface". The Adafruit breakout only brings out the SPI (serial) pins - not the other pins for the parallel interface.

This was likely done on purpose for the Arduino Uno - because it doesn't have enough pins to support it (the data/address bus alone is a 16 bit interface - with all the other pins involved, there wouldn't be enough on the Uno anyhow).

What I would look for would be a better breakout board that brings out all of these pins; alternatively, if you are brave and have a very steady hand, you could solder thin wires to the chip pins that bring out this functionality. Connect them to their own header of some sort, maybe?

Then - for the microcontroller - I would use a Mega; it has enough pins to support the parallel interface easily.

You would, of course, have to write your own custom interface library to drive the pins properly to use the parallel BTE functionality - not a small task, but the datasheet seems to give more than enough documentation to allow you to do this.

cameronasmith:
I tested this by using a for loop and drawing 1 black pixel at a time, but it takes a LONG time. I didn't time it but I think like 30 seconds.

If you are simply trying to clear the screen, or draw simple shapes (lines, rectangles, circles, triangles, etc) - the SPI (serial) interface and the Adafruit-supplied library should work fine for that; the idea being that you would build up your drawings from these simpler primatives, which are all (seemingly) hardware-accelerated. For instance, a 3D engine could (in theory) be built using only the triangle function for the output (of course, much more is needed to make a fast 3D engine on a system without a real floating-point processor).

However, if you are trying to draw and move sprites or other bit-blitting operations - that isn't supported (according to the documentation) by the SPI (serial) interface - only by the parallel interface, which as mentioned before, has not been broken out by the Adafruit board.

cameronasmith:
Can anyone recommend a way of increasing the speed of this? I know that the TFT driver is capable of super fast drawing and that it is my end which is slowing things down.

I was thinking of buying the Arduino Due, but not sure if it this would even be up for the task!

Well - I think you can see that I have already recommended what you should do; namely, either find or build a better breakout board and use an Arduino Mega for the controller (so you have enough pins), or modify/hack the existing breakout board to bring those pins out. Likely, the former will be easier (or no more difficult) than the latter, and will result in a better system less prone to failure overall.

Moving to a Due will not likely solve your problems with the speed of the interface; you will still be constrained to the speed of the SPI transfers (which can only happen so fast), and you still won't have access to the BTE blitting engine - which is where things will really shine. If you do buy/build/modify a better breakout board for the RA8875, though - a Due could help immensely with speed (over a Mega) - plus the floating-point performance should be much better as well (if you plan on doing anything 3D related or you need floating-point functionality for other reasons - like moving sprites in a sine-wave fashion or such). Again, with clever programming, fast floating-point can be had using integer math, but it isn't intuitive to implement.

I hope this helps.

On a side note, I found it interesting in the discussion of the parallel interface (page 56) that they have a pin to select between using an 8080 or 6800 series MCU interface. In theory, you could connect this chip to an Altair 8800! I also like the idea of hooking one up to my TRS-80 Color Computer (6809). Likely you could interface this chip to any of the old machines from the 1980s and it would work ok.

In theory, you could connect this chip to an Altair 8800!

Cool. Too bad I don't have mine anymore.