PDA

View Full Version : Teensy 3.* - Text rendering issue with RA8875 TFT display



slgonzalez
12-16-2013, 02:49 AM
Hello,

I am a really big fan of the Teensy family and have been using the Teensy 2, 2++ for quite a while now. I recently bought a pair of Teensy 3.1s and am amazed at the speed and power of these tiny boards.

I have a 5" TFT touch display from Adafruit (http://www.adafruit.com/products/1596), controlled through SPI by an RA8875 driver board (http://www.adafruit.com/products/1590), programmed using their library (https://github.com/adafruit/Adafruit_RA8875). On an Arduino Uno and a Teensy 2, everything works just as expected. I tried running the same program on a Teensy 3.1 and everything works fine, except that the text rendering is screwed up. Rendered text shows up as a jumble (not even real characters). I get this issue both with my custom program and the library's example program. I feel this might have to do with the Teensy 3.1 having a 32-bit processor.

Expected (w/ Arduino Uno):
1222

Bad Rendering (w/ Teensy 3.1):
1223

Thanks in advance!

MichaelMeissner
12-16-2013, 03:20 AM
I took a quick scan at the RA8875 and GFX libraries, and the current version looks like it does not use int or unsigned int at all. All integers look like they are declared as uint8_t, int16_t, etc. The only place char was used was as a text string (chars are unsigned by default in Arm processors, and signed in AVR processors, so if you use char as a small signed int, it would be a problem). Just to be sure, you might want to see if you have the latest version of the RA8875 and GFX libraries.

The only other thing that comes to mind is it does SPI. You might check if they are using hardware SPI or software SPI. I imagine if they are doing software SPI, you might need to adjust timings.

slgonzalez
12-16-2013, 08:43 PM
The only other thing that comes to mind is it does SPI. You might check if they are using hardware SPI or software SPI. I imagine if they are doing software SPI, you might need to adjust timings.

They are using hardware SPI.

MichaelMeissner
12-16-2013, 09:30 PM
Given there have been some issues with Teensy 3.1 and 1.17, I suspect you might want to wait for the 1.18. Perhaps it is one of the bugs Paul has found since 1.17 came out.

PaulStoffregen
12-16-2013, 09:35 PM
Except for OctoWS2811, all known problems manifest as compile errors. This is something new.

Constantin send me one of these LCDs, which just recently arrived. I'll probably work with it on Wednesday or Thursday. Sorry, I just can't get to this sooner.

manitou
12-19-2013, 02:35 AM
An easy thing to try: in the library's textWrite(), make the delay(1) unconditional ....

PaulStoffregen
12-19-2013, 08:11 PM
@maitou, you called it... I just dug through the code and found this myself. Shoulda read your comment first!!

Here's a fixed copy.

https://github.com/PaulStoffregen/Adafruit_RA8875

slgonzalez
12-19-2013, 08:50 PM
Thank you so much for taking the time for this! It works now!

PaulStoffregen
12-24-2013, 10:24 PM
Adafruit has merged this fix into the official library. :)

vcaha
07-01-2014, 05:53 PM
I'm looking at the feasability using one of these TFT's for an application that involves full-screen text with scrolling. I've got the Adafruit 2.8" TFT shield (https://www.adafruit.com/products/1651) on a Duemilanove using SPI, and the speed at which it can draw a screenful of characters is too slow, but not by a huge margin. This shield is only set up for SPI, but I also have Adafruit's 2.8" TFT breakout version which supports an 8-bit mode that uses more pins but Adafruit says is faster (not sure how much until I test).

Do these TFT screens update any faster with the Teensy (compared to Uno/Duemilanove or Mega)? I did find this youtube video (link (https://www.youtube.com/watch?v=6EvJUABbedQ)) comparing TFT refresh speeds of a Due vs Mega (the Due is fast enough for my needs, Mega is not). I would assume the Teensy 3.x should be in the same neighborhood as the Due, right?

Has anyone compared

TFT on regular Arduino with SPI
TFT on regular Arduino in 8-bit mode
TFT on Teensy with SPI
TFT on Teensy in 8-bit mode


Thanks.

PaulStoffregen
07-01-2014, 11:29 PM
8 bit mode with the UTFT library is very fast.

manitou
07-03-2014, 09:10 PM
Has anyone compared

TFT on regular Arduino with SPI
TFT on regular Arduino in 8-bit mode
TFT on Teensy with SPI
TFT on Teensy in 8-bit mode


Thanks.

I don't have newer SPI version, but this thread has some results for 8-data lines on DUE, UNO, maple and teensy 3*
http://forum.pjrc.com/threads/16798-2-8-quot-TFT-touchscreen-Teensy-3-0?p=50374&viewfull=1#post50374

local_dani_21
11-08-2014, 01:24 PM
Hi, I'm trying to do the same as slgonzalez:



I have a 5" TFT touch display from Adafruit (http://www.adafruit.com/products/1596), controlled through SPI by an RA8875 driver board (http://www.adafruit.com/products/1590), programmed using their library (https://github.com/adafruit/Adafruit_RA8875). On an Arduino Uno and a Teensy 2, everything works just as expected. I tried running the same program on a Teensy 3.1 and everything works fine...

I also have the display running well under 32U4 and teensy++ 2.0, but when I try to use it under teensy 3.1, the program stops at
tft.begin(RA8875_800x480); without any notice. I tried both adafruit's ra8875 (https://github.com/adafruit/Adafruit_RA8875) and paul's ra8875 (https://github.com/sumotoy/RA8875) libraries but nothing changed. I power the teensy 3.1 by USB but have tryied it with external power sources - no difference.

My wiring:



teensy 3.1 pins | ra8875 breakout from adafruit
________________|_________________________
Vin | Vin
Gnd | Gnd
9 | RST
10 | CD
11 | MOSI
12 | MISO
13 | SCK



Slgonzalez: Would you mind giving me your wiring? Or is there anything else that has to be done to teensy 3.1 to make it run the code?

Thank you in advance!

Dani

local_dani_21
11-08-2014, 08:06 PM
I got TextMode right - sorry to bother you. I now tried even another version of RA8875 library; the Adafruit_RA8875 library that was changed by Paul: https://github.com/PaulStoffregen/Adafruit_RA8875. With this library, Arduino IDE 1.0.6, teensy 3.1, the 5" TFT and adafruit's RA8875 breakout board, it all works well. Dani

local_dani_21
11-08-2014, 08:18 PM
Another question I have though: sumotoy (mentioned above: https://github.com/sumotoy/RA8875) has a few nice sounding examples in his library: mandelbrot, 3D-examples etc. They compile in Arduino IDE 1.0.6 using Paul's library but are not displayed on the TFT. I assume a timing problem somewhere but have no clue where to look. Does anyone have an idea? Thanks, Dani

local_dani_21
11-15-2014, 09:53 AM
I just found out with adafruit rick's help (https://forums.adafruit.com/viewtopic.php?f=47&t=60533&p=320674#p320674), that the very same code
/************************************************** ****************
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 UNO Digital #13 (Hardware SPI clock)
// Connect MISO to UNO Digital #12 (Hardware SPI MISO)
// Connect MOSI to UNO Digital #11 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
#define RA8875_INT_2 2
#define RA8875_CS_2 8
#define RA8875_RESET_2 7

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

void tftSetup(Adafruit_RA8875 *tft)
{
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);

}

void setup()
{
Serial.begin(57600);
while(!Serial){}
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");

Serial.println("RA8875 2 start");

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

Serial.println("Found RA8875 2");

tftSetup(&tft);
tftSetup(&tft2);

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);
}
}
} with the same setup (two RA8875's connected to one a microcontroller) works on a Arduino UNO (ATMEL 328P) but not on a Arduino YUN (32U4) nor a teensy++ 20 (AT90USB1286) nor a teensy 3.1 (MK20DX256) where I always get an error when initializing the first RA8875 on the SPI-bus

Terminal output:
RA8875 start
RA8875 Not Found!.
Does anyone have any idea in what aspects SPI on these processors (32U4, AT90USB1286, MK20DX256) differ from an ATMEL 328P?

local_dani_21
11-15-2014, 10:13 AM
PS: When I use a teensy 3.1 and Pauls version of the RA8875 library https://github.com/PaulStoffregen/Adafruit_RA8875 in Arduino IDE 1.0.6, then the terminal output differs slightly:

RA8875 start
Found RA8875
RA8875 2 start
RA8875 2 Not Found!

PaulStoffregen
11-15-2014, 12:20 PM
Ugh, looks like I might have to get a 2nd RA8875 to work on this problem.

Could you please post a photo of the test hardware using Teensy 3.1? Let's at least look quickly at that. Then I'll peek at the code, and if nothing seems obviously wrong, looks like I'll get a 2nd one from Adafruit next week....

local_dani_21
11-15-2014, 12:44 PM
My setup looks as follows:

Teensy 3.1 | RA88751 | RA88752
-------------------------------
5V | VIN | VIN
GND | GND | GND
10 | CS |
9 | RST |
8 | | CS
7 | | RST
SCK (13) | SCK | SCK
MOSI (11) | MOSI | MOSI
MISO (12) | MISO | MISO

2948

The post above contains the code I'm trying to run.
As mentioned before, when replacing the teensy 3.1 / teensy++ 2.0 with a barebone Atmega 328P, the setup works well.
Thank you for looking at it. Dani

local_dani_21
11-17-2014, 08:08 AM
Paul, adafruit support guy Rick was able to reproduce the failure when using an Arduino Yun (32u4); he also found out that the two display setup does work with an Arduino MEGA, but not with plain Arduino LEONARDO's (32u4) [for me: as expected, since same chip as on the YUN]. I don't have any teensy 2.0 anymore, so I cannot check that, but I expect it not to work since it uses the same processor.

Have you had an idea what the problem might be between the implementations of SPI?

PaulStoffregen
11-17-2014, 08:51 PM
Ok, I've ordered a 2nd RA8875 and 5 inch LCD. If you don't hear from me by next Monday, post a reminder...

local_dani_21
11-17-2014, 09:20 PM
Ok, I've ordered a 2nd RA8875 and 5 inch LCD. If you don't hear from me by next Monday, post a reminder...
I'll be glad to!

local_dani_21
11-20-2014, 11:34 AM
BTW: So far I'm able to get images from the RPi to the Arduino Mega over http/ethernet. That works ok, but is of course not as elegant as the Bridge-version of the Arduino Yun. If you're still into looking to port the bridge to other communication protocols or processors - I'm standing by to help/test. Regards, Dani

PaulStoffregen
11-20-2014, 11:57 AM
Also being discussed on Adafruit's forum. My main reference is this forum, so here's a link to the latest over there... so I remember to follow up in both places.

https://forums.adafruit.com/viewtopic.php?f=47&t=60533&p=322091#p322091

PaulStoffregen
11-20-2014, 11:59 AM
If you're still into looking to port the bridge to other communication protocols or processors - I'm standing by to help/test.

How about this?

https://github.com/PaulStoffregen/Bridge

local_dani_21
11-21-2014, 04:49 PM
How about this?
https://github.com/PaulStoffregen/Bridge

Cool! The problem remains the linux-side of the bridge. I'm not the python guy, so I started a post in the arduino.cc forum http://forum.arduino.cc/index.php?topic=280585.0 ... let's see what people think.

PaulStoffregen
11-24-2014, 03:37 AM
The problem appears to be hardware, that the RA8875 chip does not tri-state its MISO pin when CS is high.

Here is the example, with both MISO pins run through a 74HC125 tri-state buffer chip, controlled by the 2 chip selects.

2990
(click for full size)

local_dani_21
11-24-2014, 07:29 AM
Hi Paul - so do you think that the tri-state-buffer is the solution and will solve all the conflict's I'm having? Thank you! Dani

PaulStoffregen
11-24-2014, 09:33 AM
Hi Paul - so do you think that the tri-state-buffer is the solution


It certainly looks that way.

I confirmed by hardware testing with resistors that the MISO pin was driven while CS was not asserted. When a chip tri-states the MISO pin, the resistors should take the pin to a voltage half way between GND and VCC. The voltage remained 3.3V (actually, a little less, since that chip doesn't drive very hard, but clearly still driving the line). You can pretty easily duplicate this test by just connecting two 10K resistors to MISO, and measure the signal with a scope or even a voltmeter when the display isn't being updated.



and will solve all the conflict's I'm having?

Yes, I believe it will. 2 displays that didn't work together, and which I confirmed were conflicting on MISO, clearly do work with the 74HC125 buffer added.

When the 3rd display arrives, probably within the next 16 hours, I'll hook it up and try your 3-display test with the SD card. I'm only going to run the test on Teensy 3.1. If that works, and I'm pretty confident it will, I'm going to consider this fully "resolved".

I sincerely hope Adafruit documents this limitation on their website and eventually makes a new version with the buffer and 2 pullup resistors. But that's really up to Adafruit. I have no control over what they do. I've done pretty much all I can here.

local_dani_21
11-24-2014, 09:56 AM
That is SOOOO cool! Thank you very much for your endurance and expertise! I'll do the installation with a teensy 3.1 anyway since it is a lot faster than it's 16MHz counterparts. I asked adafruit for some of the 74HC125 chips and hope to make a little daughterboard soon.

local_dani_21
11-24-2014, 03:53 PM
Hi Paul, may I ask you a favor? I tried to set up what you did and failed - I seem to have gotten something wrong. Would you (or anybody reading this) go over my schema to find the mistake? Thank you very much, Dani
2998

PaulStoffregen
11-24-2014, 09:13 PM
Yup, that looks exactly like what I did. I used the 2 buffers on pin 1-6, but otherwise it looks exactly the same.

local_dani_21
11-24-2014, 10:44 PM
Weird, I don't understand it. Are you using the standard Adafruit RA8875 library? At the moment, I'm not even getting anything when I use only one display on a teensy 3.1.

PaulStoffregen
11-24-2014, 10:50 PM
Something's probably not connected properly.

Yes, using the normal code, no modifications. I only added the 74HC125 chip.

local_dani_21
11-24-2014, 10:52 PM
Well, I just switched to your library and now it worked. There seems to be a difference.

Actually: Now EVERYTHING is well! I'm so glad and thankful to you!
I have to go to bed - and get up again in 5 hours to go earn some money!
Dani

PaulStoffregen
11-25-2014, 01:58 AM
I published a blog article about these & other issues.

http://www.dorkbotpdx.org/blog/paul/better_spi_bus_design_in_3_steps

Hopefully this word can spread. If everyone in the Arduino world becomes more aware of these issues, hopefully someday shields and breakout boards without tri-state and pullups will become a relic of the past.

local_dani_21
11-25-2014, 07:12 PM
Paul, you should send that link to adafruit support or post it in adafruit's forum!

local_dani_21
11-26-2014, 07:45 AM
I just connected 3 RA8875's with corresponding 5" TFT's (800x480) to a teensy 3.1. When using the MISO tri-state buffers and the pullup resistors on the CS- and RESET-lines, the setup works like a charm. However - the displays draw quite some power, each of them about 250mA @ 5V. Since the teensy 3.1 only delivers 500mA through USB, one has to consider an external power source that is connected directly to GND and VIN.

PaulStoffregen
11-26-2014, 09:38 AM
Glad to hear it's working.

I've exchanged emails (privately) with Adafruit and others. My influence is limited. Often the most effective way involves working behind-the-scenes, which never becomes public. I really can't comment on private communication, but I can assure you, I'm doing everything I can to improve compatibility of all Arduino-based products.

Adafruit gave me access to repost my article on their learning site. Figuring out how to use their learning site and posting it there is on my TO-DO list for this weekend.