I recently purchased a 3.5 inch TFT shield for Arduino Mega (https://ebay.to/34yC6UQ) with the MEGA 2560 (https://ebay.to/3kBwcrr) to make a digital photo frame for my girlfriend, but I've been having trouble getting it to work. When I plug it in and try to run code, the screen stays white and does not change. After researching for a few hours, I was able to find that removing '&& USING_16BIT_BUS' from "#if defined(SUPPORT_1963) && USING_16BIT_BUS" in the MCUFRIEND_kbv.cpp file allowed me to display graphicstest_kbv on the TFT. I don't have any other TFTs to display graphicstest_kbv on, so I'm not sure if it's working properly, but it at least displays. It looks like the graphicstest code needs to have "ID = 0x9481" to function. I'm new to Arduino and all of these electronic components so I'm not great at troubleshooting yet, so any help is appreciated.
I'm not sure if any of this is relevant, but here's some extra info if you need it:
-The eBay seller listed it as a ILI9486 chip driver
-All the back of the display says is " 3.95" LCD Module for Mega2560 "
-There are 5 (resistors?) on the back labelled R1 through R5. It also says in a little table next to it, R5 16Bit (DB0~DB15) and R4 8Bit (DB0~DB7)
-There are five chips labelled U3 through U6.
-Unlike some other LCD modules I've seen, there are not two pins on the side of the module
-There are 36 pins total
-What I believe to be the touchscreen layer has a code "HSD-9190J-A6" written on it
As of writing this, I'm trying to run mcufriend's "showBMP_not_Uno" without much luck. The serial monitor states "cannot start SD" and the TFT displays half light blue and half grain (image attached below). I currently have 4 BMP images on the SD in the root directory. I'm going to try and go through the code and see why it's not working, but I'd appreciate any help. Let me know if you need more information.
From what I can tell, the colors are inverted, some of the text is backwards, and in some situations there is the same grain that I'm seeing when I try to run the SD code.
First off. Thanks for the photo. Better than a 1000 words.
Install / upgrade the MCUFRIEND_kbv library via the IDE Library Manager
From C:\Users...\Documents\Arduino\libraries\Mcufriend_kbv\extras\mcufriend_how_to.txt
17. If you do not have a standard Uno Shield, you can add a SPECIAL to the mcufriend_special.h
Edit mcufriend_shield.h: #define USE_SPECIAL
Edit mcufriend_special.h: e.g. #define USE_MEGA_16BIT_SHIELD
If your "special" is write-only, the library can not read the ID. It always returns 0xD3D3
For your particular shield you #define USE_MEGA_8BIT_PORTC_SHIELD
When you bought the shield it would have come in an antistatic envelope. If it specified ILI9486 then you edit all your sketches like this:
uint16_t ID = tft.readID(); //
if (ID == 0xD3D3) ID = 0x9486; // write-only shield
tft.begin(ID);
If your envelope said ST7796S then you should say
if (ID == 0xD3D3) ID = 0x7796; // write-only shield
Your shield is write only.
It uses an XPT2046 Touch Controller chip. So you need XPT2046_Touchscreen.h library
Please get it working in the default mode. Report back. I will then show you how to change to 16-bit mode.
Thanks so much, working like a charm now. I had USE_MEGA_16BIT_SHIELD uncommented in my mcufriend_special file, but switching to USE_MEGA_8BIT_PORTC_SHIELD fixed it. I must have thrown out the envelope with the packaging so I can't check whether it's 9486 or 7796, but the 0x7796 code worked perfectly--no mirrored text, incorrect colors, etc. I installed the XPT2046_Touchscreen.h library. Do I need to configure the CS_PIN and TIRQ_PIN? The default in the TouchTest code is 8 for CS_PIN and 2 for TIRQ_PIN. The display has two pins labelled TP_CS and TP_IRQ, but I'm not sure if I need to remap the code to fit those pins.
I would advise configuring 16-bit. With soldering iron remove 0R from R4 and put on R5. You will probably lose the 0R, so a solder blob will do the same thing.
Then define USE_MEGA_16BIT_SHIELD
This will let you use MCUFRIEND_kbv. And many other ILI9486 libraries e.g. UTFT, TFT_HX8357, ...
Yes, you need to use 53 for TP_CS. And you can use 44 for TP_IRQ (or 255 to ignore)
Note that you use 48 for SD_CS
I switched it to USE_MEGA_16BIT_SHIELD and everything seems to be running fine. In TouchTest, I set #define CS_PIN to 53 and #define TIRQ_PIN to 44. Should I see something in the serial monitor? It's blank when I run the code. Also, I don't see SD_CS anywhere in the code.
Thanks, it works great. The pictures look amazing and I don't see any issues. Is there any way to change the code so that it does not change to a black background before loading each picture? I'd like it to be able to stay on the previous picture and load the new picture down overlapping it until it finishes. Also, is there any way to speed how fast the picture changes? I've seen online that there's limitations due to the max speeds of the Arduino, but I'm not sure if there's anything I can do to shorten the time between photos. I have a few other miscellaneous things I'd like to change but I'll try changing the code on my own to see if I can do them. If not, I'll probably have some more questions for you :).
Thanks for all of your help so far. You're a lifesaver.
I was able figure out the black background issue I was talking about. I've also been doing some more research about the coding and terms so I have a better understanding. I'm still having trouble getting touch to work, though. In the XPT2046 Touchscreen library I was able to register touches in the serial monitor but I haven't been able to do much else. With my display, do I need to know the XP, YP, XM, and YM pins? I saw in another thread you had replied to that XPT2046 chips control the different plus/minus pins. What does this mean for using the touchscreen? I'm not sure if it's possible, but I'm thinking about creating a GUI where one can select a folder to choose a group of photos to playback as a slideshow on my TFT. What's the best way to go about designing this?
Then make a nice cup of tea. And design how you want your program to behave.
Then code according to your Flowchart.
If you have a problem, you have already designed your project. So you just need to copy-paste or photograph your logic. And ask for help on this specific item in your design.
I’m here with hopes for getting help using similar kind of tft like the thread starter has but with Teensy 4.0. My shield is also for Mega2560 but this one: 3.95inch Arduino Display-Mega2560 - LCD wiki . It’s a 3.95" ST7796S device configured as 8-bit.
Before going any further I have a question: Is my pinout correct? I’m asking this because in my opinion those MXRT pin labels seem to refer to Teensy 4.1. Means I've at least seen a table showing those labels for 4.1 but not for 4.0.
I’ve also trouble finding out where to connect pin 6.16 (pin 19 on my board)? In every schematic I’ve found for UNO tft shields A5 is shown as NC or "free". But it’s still listed here as Teensy 4.0 pin.
//####################################### TEENSY 4.0 ############################
#elif defined(__IMXRT1062__) // regular UNO shield on a Teensy 4.x
#warning regular UNO shield on a Teensy 4.0
//LCD pins |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |RD |WR |RS |CS |RST | A5
//MXRT pin |7.17|7.10|9.8|9.6|9.5|9.4|7.11|7.16| |6.18|6.19|6.23|6.22|6.17|6.16
I do have a Teensy 4.0
I don't have a Teensy 4.1
I do have a Teensy 3.2
(((GPIO7_PSR & (1 << 16)) >> 16) //definitely refers to GPIO 7.16 i.e. LCD_D0 on Mcufriend shield
Both 4.0 and 4.1 seem to use the same IMXRT1062 MCU
Since you are hand wiring all the pins to the Teensy 4.0 it should work straight out of the box.
You have probably noticed that all shield wiring refers to regular Uno Shields e.g.
So as far as I understand physical connections from the board to the shield are correct in respect how the library is defining and using Teensy's IO ports.
MCUFRIEND was installed via IDE Library Manager. I enabled #define USE_SPECIAL and #define USE_MEGA_8BIT_PORTC_SHIELD as well as forced ID = 0x7796; before tft.begin. All #define SUPPORT_ options were as out of the box.
Result? Well, nothing but white screen. This same shield works ok on ESP32 with TFT_eSPI but the library doesn’t currently support parallel interface with "generic" CPUs like Teensy. That is one reason I started looking into MCUFRIND but now this looks like kind of dead end as well. Or is there anything still to be done or try?
No, you don't need a SPECIAL if you connect the LCD_xx pins to A0-A4 and the DB0-DB7 pins to 8,9,2-7
Mind you, since you are building for a Teensy the SPECIAL would not have matched anyway.
I suspect that a Teensy owner probably owns a Mega2560 too.
So it would be wise to plug the Shield into a Mega2560
MCUFRIEND was installed via IDE Library Manager. I enabled #define USE_SPECIAL and #define USE_MEGA_8BIT_PORTC_SHIELD as well as forced ID = 0x7796; before tft.begin.
That should make it work on the Mega2560. God gave you Shields so that wiring is a known quantity.
I possess a Teensy4.0 which is mounted on a Protoboard together with Arduino Uno headers.
I can swap any Uno shield without worrying about the wiring.
I have never made the equivalent for Mega2560 shields. Let's face it. Mega2560 shields fit on Mega2560 and Due. If you own a Mega2560 or a Due, why would you ever want to hand-wire a shield? Both Mega2560 and Due accept Uno Shields and Mega Shields.
Ok I understand now. I anyway have an UNO but not Mega2560, I’m more interested in ESP and Teensy worlds. I got two of those tft Mega shields almost for nothing so I’m just looking around to see if there would be any (easy so-to-say) way to utilize them with those other MCUs. This is because my perspective is more or less end-user and my coding skills would fall short quite quickly…
But thinking about UNO and Mega shields for a certain (same) tft controller I’ve had an impression that they are basically identical apart from pin patterns. Means - when leaving out touch, sd etc. features - if you get in this case the critical 13 pins right on both shields the rest would be "just" programming. But this not the case after all, or how is it?
Yes, it is 8 data and 5 control pins for the 8-bit controller e.g. on Uno shield.
I know exactly which port pin goes to 2-9, A0-A4 for each Arduino.
I follow the same pattern for Teensy. Mr Stoffrogen has kindly specified Arduino digital and analog pin numbers for his Teensys. So you just wire each display pin to the appropriate number printed on the Teensy.
You just have to be meticulous. Post a clear photo if you want extra eyes to check your work.
Personally, I think that parallel displays waste a lot of GPIO pins. A Teensy can drive an SPI ST7796S plenty fast enough. Likewise ESP8266 or ESP32.
However you have a choice with Teensy and ESP32. They have enough pins for Parallel 8080-8 interface.