320 x 480 TFT ILI9481 Slow on MEGA

Hello forum,

This is my first go with TFT shield displays, a step away from the 2 x 16 LCD's I'm used to. I bought two of these displays on EBAY (https://www.ebay.co.uk/itm/3-5inch-TFT-Color-Screen-Module-320X480-Ultra-HD-LCD-Shield-for-Arduino-UNO-FT/112790945520?hash=item1a42dd3ef0:m:miQ_f6oi8m3Qb6KK72-o1Mg)

It is advertised for use with UNO's, and it works great on them, but I slapped the TFT shield onto a MEGA and it works without having to alter the code. Only problem is that is performs at about 60% of the speed on a MEGA compared to on an UNO.

I would have thought this would be the other way around. Does anyone know the reason for this? Is there something I can adjust in the wiring or code to get this display as snappy as on the UNO?

Thanks,
Hein

These Shields are designed for a Uno. They work at a pretty good speed on a Uno.

Yes, it will work on a Mega (and Zero, Due, Leonardo, Nucleo, …) but SLOWER.
This is because it is mapped to sensible pins for a Uno but these are random Port pins on the other targets.

If you want to run a display on a Mega, buy a Shield that is designed for the Mega.
Or hand-wire an Adapter with a Protoshield.

MCUFRIEND_kbv has always had USE_MEGA_8BIT_PROTOSHIELD in its SPECIALs
Yes, the Mega will work FASTER than the Uno with USE_MEGA_8BIT_PROTOSHIELD

Incidentally, my Blue ILI9481 Shield gets quite hot to the touch.

David.

I would have thought this would be the other way around.

No they should be the same.

I suspect that the libiary checks to see if the SPI pins are on the same pins as the Uno uses and when it finds a MEGA, it knows it can not work with the hardware SPI because these are on different pins and so resorts to bit banging the SPI protocol.

To change this so that it works on the MEGA at the same speed as the Uno then you have to rewire the module so it uses the pins that the MEGA has for SPI and alter the libiary so that it does not change the way it drives these pins.

Just a guess but I would be surprised if I was wrong.

You will be surprised !!!

David.

The project I’m working on will have the display embedded in a hinged door, with the mega inside the enclosure with a ribbon connecting the two. I want to do this to keep the inside of the door as flat as possible, so I don’t want the mega cluttering up that space.

So I will be connecting the two with leads anyway. If I was to connect the TFT to the right ports on the mega, how complicated would it be to change the coding for it to work at top speed?

We’re based in Africa - getting a protoshield here is going to take another two weeks, cannot wait that long.

Would one of these be of any use?

Shields are one of the best features of Arduino. Standardised software and standardised hardware.

I would never advise random jumper leads. Well made ribbon cables are better.
If you wire it carefully it would be electrically the same as a Protoshield Adapter e.g. USE_SPECIAL and USE_MEGA_8BIT_PROTOSHIELD.

Make sure that you connect to 3.3V, 5V, GND.

David.

Would one of these be of any use in connecting the two, or do we only need straight connections?

Screen Shot 2018-06-03 at 3.25.33 nm..png

That Adapter is for 40-pin 3.3V displays.

Your Shield just needs straight wires e.g. LCD_D0 - LCD_D7 go to D22 - D29 on the Mega,
LCD_RD . LCD_RST go to A0 - A4 on the Mega. GND to GND. 3.3V to 3.3V. 5V to 5V.

David.

Thanks David for taking the time.

I uncommented "USE_MEGA_8BIT_PROTOSHIELD" in mcufriend_special.h. Is there code I need to add to my sketch to complete this?

GOt it!

I missed #define USE_SPECIAL .

Thanks David!!

You may have anticipated this newbie's next question...

When I had the shield stuck directly onto the MEGA I had the SD reader working by bending out the four SD pins and wiring them to D50 (SD_00), 51 (SD_01), 52 (SD_SCK) and SD_SS going to GND. Worked beautifully.

Now that I've connected the shield as per your instructions the screen updates like a wildfire but SD won't initialise.

What do I need to change on this wiring to get it going again?

Many thanks,
Hein

You either re-route the microSD SPI pins (D11-D13) to D50-D52 e.g. showBMP_kbv_Uno
Or you use software SPI on D11-D13 e.g. showBMP_not_Uno

Software SPI involves using a third party SD library. Instructions in showBMP_not_Uno

David.

What happens with SD_SS? GND, 53 or 10?

david_prentice:
You will be surprised !!!

David.

OK care to enlighten me, and others, or is it a secret?

To me everything you have said so far seems to align with my guess.

Take it easy Grumpy_Mike.

I've been trying to get SdFat to work like showBMP_not_Uno instructs, but I keep on getting "'SdFatSoftSpi' does not name a type".

I uninstalled the version of SdFat I had, installed and ran all "official" versions on the IDE list, from 1.0.1 through 1.0.5. All give the same result.

What am I missing?

David, great library by the way. I'm chuffed at my new TFT speed.

Grumpy_Mike:
OK care to enlighten me, and others, or is it a secret?

To me everything you have said so far seems to align with my guess.

These particular Shields use 8080-8 parallel interface for the TFT.
And SPI for the microSD

Very few display boards or modules make the IM# pins available to the user.
The displays are manufactured for 8080-8, 8080-16, SPI, ... interface and you cannot alter it.

Some displays from Adafruit and EastRising do let you change the IM# pins.

Surplus parallel 8080-16 and 8080-8 displays are cheap. SPI capable displays are expensive.

David.

heinburgh:
I've been trying to get SdFat to work like showBMP_not_Uno instructs, but I keep on getting "'SdFatSoftSpi' does not name a type".

I uninstalled the version of SdFat I had, installed and ran all "official" versions on the IDE list, from 1.0.1 through 1.0.5. All give the same result.

If you route the microSD to the Mega's hardware SPI pins, the SD.h library works out of the box. e.g. showBMP_kbv_Uno
Obviously you must set an appropriate SD_CS define. i.e. 53 if you re-routed SD_CS to 53.

There is no need to use the SdFat.h library if you re-route.
If you use a Uno shield on the Mega, you must use SdFat because the microSD is on the Uno SPI pins.

Note that you have to configure SdFat library i.e. edit a library H file.

David.

I'm using an UNO shield on a MEGA. Simply because I didn't realise my mistake until after the item arrived. It's from China on EBAY and the sell it as UNO/MEGA shield.

Could you point me to the right direction for the edits to the SdFat library file?

The instructions are in the showBMP_not_Uno sketch.
If you have a question, quote the instruction that you do not understand.

This will help me to improve the instructions.
Especially for non-English speakers but improvements for Brits / Americans would be good too.

David.