1.8" TFT shield with joystick and SD card on chipKIT

blackstealth
Posts: 6
Joined: Wed Jul 17, 2013 7:55 pm

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by blackstealth » Tue Sep 17, 2013 5:08 pm

ST7735 via SPI can be very fast, start video at 2:00 minute mark. Take a look here:
http://www.youtube.com/watch?feature=pl ... Mlkg#t=127

I believe the SPI was done by DMA for max speed to transmit frame buffer.

Here's a chart showing how much impact DMA has on SPI transfers on maple:

SPI clock, non-DMA (efficiency%), DMA (efficiency%)
-----------------------------------------------------------------
1.125MHz, 0.85mbs (75%), 1.125mbs (100%)
2.259MHz, 1.35mbs (60%), 2.250mbs (100%)
4.500MHz, 1.80mbs (40%), 4.500mbs (100%)
9.000MHz, 2.20mbs (24%), 8.900mbs (99%)
18.00MHz, 2.20mbs (12%), 17.80mbs (99%)
http://forums.leaflabs.com/topic.php?id=1075&page=2

I believe we will see the same kind of impact on our PIC32 microcontrollers if we enable DMA to do the work of transferring SPI data to ST7735 display. On the very bottom of the chart, DMA was 8x faster than non-DMA.

User avatar
majenko
Site Admin
Posts: 2165
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by majenko » Tue Sep 17, 2013 5:47 pm

Quite possibly, and I did briefly think about it when initially working with the framebuffer system. However I almost immediately ruled it out as it can't do the palette lookups inside the DMA, and a 16 bit framebuffer would rule out the smaller chips. I might create a 16 bit framebuffer device for the 695 and 795 that is DMA driven. I have also been thinking about DMA block transfers in the palette version - have a pair of scanlines in 16 bit depth and fill one while transferring the other.

Edit: I have just been having a play, and it is going to be next to impossible to shoehorn DMA transfers into the system as it stands. The problem is the DSPI library. There is no clean way of the TFT system knowing which underlying SPI port is in use, so it can't set up the DMA transfer to the right stream. The logical place to put it would be in the DSPI library itself. In fact, the DSPI library could do with a little bit of work to make it more efficient and tidier. I could embed my own SPI library into the TFT system, but it really doesn't belong there, and I don't want to conflict with other SPI systems.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

blackstealth
Posts: 6
Joined: Wed Jul 17, 2013 7:55 pm

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by blackstealth » Wed Sep 18, 2013 12:38 am

The ST7735 also accepts 12 bit palette (R-4, G-4, B-4), instead of the usual 16 bit palette. This means it takes 25% less memory, and likewise 25% less data needs to be transferred via SPI, should translate into 25% speed bonus. This works out to be 30KB of graphics frame memory, which is doable on my PIC32MX250f128 (32KB ram).

User avatar
majenko
Site Admin
Posts: 2165
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by majenko » Wed Sep 18, 2013 3:40 pm

Except... You can't do 12-bit SPI, so you'd have to either do separate 8-bit transfers, which is slower than single 32-bit transfers, or pack the 12-bit values into a number of 32-bit clusters. That would be 8 pixels at once (96 bits) which would equate to 3 32-bit transfers.

Yes, it means you have a greater colour depth available, but is the extra overhead of compressing the data into 96 bits going to gain you much in the way of speed?
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

blackstealth
Posts: 6
Joined: Wed Jul 17, 2013 7:55 pm

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by blackstealth » Thu Sep 19, 2013 3:33 pm

Create a 30KB array of int8 and then transmitting SPI as 8bit or 32bit would be straight forward. The only challenge is making a function to insert the 12bit data into the correct array index.

array[0]=Red:4 Green:4
array[1]=Blue:4 Red:4
array[2]=Green:4 Blue:4
... and then it repeats the same again
array[3]=Red:4 Green:4
array[4]=Blue:4 ...

User avatar
majenko
Site Admin
Posts: 2165
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by majenko » Sat Sep 28, 2013 10:10 am

I have added support to the experimental TFT library for more TFT chips, fixed a couple of framebuffer bugs, expanded the comms class to make it bidirectional, created a PMP comms class, and added basic touchscreen support. I've been busy :)
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

User avatar
unexpectedly
Posts: 105
Joined: Fri Aug 23, 2013 2:31 am
Location: San Diego
Contact:

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by unexpectedly » Wed Oct 02, 2013 8:32 pm

Wow, it seems I've touched off a powderkeg! We went to a trade show and just got back... I'm completely worthless at the moment. :shock:

User avatar
majenko
Site Admin
Posts: 2165
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by majenko » Wed Oct 02, 2013 9:06 pm

You're far from worthless!

The TFT library is rapidly becoming a bit of a beast. On MPIDE it takes an age to compile, mainly due to the quantity of fonts. I have combined all the fonts together on my test system, and it compiles a little faster, but it's bigger than the core...!

I want to create a replacement core at some point, and the TFT library will be the model for it: 100% object oriented, and namespaces to provide API compatibility with chipkit and Arduino.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

hdphilip
Posts: 39
Joined: Sat Apr 14, 2012 7:54 am

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by hdphilip » Tue Jan 28, 2014 7:59 am

majenko,

Ive been trying the tft library on github, I've been getting a few errors, framebuffer and math.h i think it was, i just can't figure it out, any ideas?


Philip

User avatar
majenko
Site Admin
Posts: 2165
Joined: Wed Nov 09, 2011 7:51 pm
Location: UK
Contact:

Re: 1.8" TFT shield with joystick and SD card on chipKIT

Post by majenko » Tue Jan 28, 2014 11:32 am

It's complex - very complex.

And made even more so by your forgetting to mention what the errors are, and provide code that causes the errors.
Why not visit my shop? http://majenko.co.uk/catalog
Universal IDE: http://uecide.org
"I was trying to find out if it was possible to only eat one Jaffa Cake. I had to abandon the experiment because I ran out of Jaffa Cakes".

Post Reply