Mega + RA8875 TFT LCD 6.2" issues

Hi everyone,

Recently I bought a screen TFT LCD 6.2" (directly from China) and I wanted to connect it to my Mega board. This screen can be used with SPI and this is what I planed to use. The screen also have the RA8875 driver from RAIO. So I tried the Adafruit_RA8875 librairy to start the screen but nothing happens(the screen stays black instead of blinking white and drawing shapes).

I used the librairy example code builtest.ino. I change the original code a little bit because it was written to be used with Uno (the SPI pins for Mega aren't the same)

/******************************************************************
 This is an example for the Adafruit RA8875 Driver board for TFT displays
 ---------------> http://www.adafruit.com/products/1590
 The RA8875 is a TFT driver for up to 800x480 dotclock'd displays
 It is tested to work with displays in the Adafruit shop. Other displays
 may need timing adjustments and are not guanteed to work.
 
 Adafruit invests time and resources providing this open
 source code, please support Adafruit and open-source hardware
 by purchasing products from Adafruit!
 
 Written by Limor Fried/Ladyada for Adafruit Industries.
 BSD license, check license.txt for more information.
 All text above must be included in any redistribution.
 ******************************************************************/

#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"



// Library only supports hardware SPI at this time
// Connect SCLK to MEGA Digital #52 (Hardware SPI clock)
// Connect MISO to MEGA Digital #50 (Hardware SPI MISO)
// Connect MOSI to MEGA Digital #51 (Hardware SPI MOSI)
#define RA8875_INT 255//Not used
#define RA8875_CS 53
#define RA8875_RESET 255//Not used

Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;

void setup() 
{
  Serial.begin(9600);
  Serial.println("------------------------------------------------");
  Serial.println("RA8875 start");

  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
  if (!tft.begin(RA8875_800x480)) {
    Serial.println("RA8875 Not Found!");
    while (1);
  }

  Serial.println("Found RA8875");

  tft.displayOn(true);
  tft.GPIOX(true);      // Enable TFT - display enable tied to GPIOX
  tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
  tft.PWM1out(255);

  // With hardware accelleration this is instant
  tft.fillScreen(RA8875_WHITE);

  // Play with PWM
  for (uint8_t i=255; i!=0; i-=5 ) 
  {
    tft.PWM1out(i); 
    delay(10);
  }  
  for (uint8_t i=0; i!=255; i+=5 ) 
  {
    tft.PWM1out(i); 
    delay(10);
  }
  tft.PWM1out(255); 
  
  tft.fillScreen(RA8875_RED);
  delay(500);
  tft.fillScreen(RA8875_YELLOW);
  delay(500);
  tft.fillScreen(RA8875_GREEN);
  delay(500);
  tft.fillScreen(RA8875_CYAN);
  delay(500);
  tft.fillScreen(RA8875_MAGENTA);
  delay(500);
  tft.fillScreen(RA8875_BLACK);
  
  // Try some GFX acceleration!
  tft.drawCircle(100, 100, 50, RA8875_BLACK);
  tft.fillCircle(100, 100, 49, RA8875_GREEN);
  
  tft.fillRect(11, 11, 398, 198, RA8875_BLUE);
  tft.drawRect(10, 10, 400, 200, RA8875_GREEN);
  tft.fillRoundRect(200, 10, 200, 100, 10, RA8875_RED);
  tft.drawPixel(10,10,RA8875_BLACK);
  tft.drawPixel(11,11,RA8875_BLACK);
  tft.drawLine(10, 10, 200, 100, RA8875_RED);
  tft.drawTriangle(200, 15, 250, 100, 150, 125, RA8875_BLACK);
  tft.fillTriangle(200, 16, 249, 99, 151, 124, RA8875_YELLOW);
  tft.drawEllipse(300, 100, 100, 40, RA8875_BLACK);
  tft.fillEllipse(300, 100, 98, 38, RA8875_GREEN);
  // Argument 5 (curvePart) is a 2-bit value to control each corner (select 0, 1, 2, or 3)
  tft.drawCurve(50, 100, 80, 40, 2, RA8875_BLACK);  
  tft.fillCurve(50, 100, 78, 38, 2, RA8875_WHITE);
  
  pinMode(RA8875_INT, INPUT);
  digitalWrite(RA8875_INT, HIGH);
  
  tft.touchEnable(true);
    
  Serial.print("Status: "); Serial.println(tft.readStatus(), HEX);
  Serial.println("Waiting for touch events ...");
}

void loop() 
{
  float xScale = 1024.0F/tft.width();
  float yScale = 1024.0F/tft.height();

  /* Wait around for touch events */
  if (! digitalRead(RA8875_INT)) 
  {
    if (tft.touched()) 
    {
      Serial.print("Touch: "); 
      tft.touchRead(&tx, &ty);
      Serial.print(tx); Serial.print(", "); Serial.println(ty);
      /* Draw a circle */
      tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 4, RA8875_WHITE);
    } 
  }
}

I think my SPI wiring is correct accordingly to the Attachments. I connected the GND to VSS, the 5V to VDD, the CS to 53, the clock to 52, the MISO/MOSI to 51/50. I already tried to invert MOSI and MISO but it doesn't work better.
After, I though it might be a problem of SPI speed so I tried to change SPI speed and SPI mode in the librairy but nothing happens... I'm a beginner in touching Arduino librairy so I don't touch it too much.
I don't know what to do next. If you have any remarks on the work I did or any problems I missed, please tell me :slight_smile:

I attach the Specs of the screen and all the pictures to control my wiring.

Thank you all

SPI Mega Pins.PNG

SPI Screen Pins.jpg

GH80080-62M01_datasheet_English.pdf (401 KB)

BuyDisplay sell an Arduino shield that will accept your 3.3V display (and do the necessary 3.3V level conversions)

The Mega2560 will only run at 5V. If you do not want to buy an Adapter shield, buy a Due or Zero which both have 3.3V GPIO.

Note that BuyDisplay provide all the necessary documentation. Especially on how to interface with a microcontroller.

David.

Thank you for your answer.

I understand my mistake now. I did some researchs on what you said. Maybe it's a better solution to use a 4-channel (one for each SPI's pins) logic level converter bi-directionnal 5v-3.3V. I think it might be cheaper than using an another shield (it's space consuming and may cause some issues because at the end of my project, I will use the microSD shield that I already have).
I must add a little breadboard between the Arduino and the screen. Each wires of the SPI from the MEGA will go through the converter and it will go down to 3.3V. It's bi-directionnal so it'll be more convenient for the MISO/MOSI pins.

What do you think about this solution?

That should be fine. The SPI is unidirectional so you don't need to worry about which type of converter to use.

You do not say which part number of converter you have.

There are some serious considerations when it comes to the backlight power on the bigger displays.
Since you are buying some expensive components it is worth being careful.

David.