Need help with problem on ST7735 and mega2560

I am trying to develop a system to rotate a stepper motor and give feedback on position. The connection I am using to the Adafruit library is:

//Adafruit_ST7735 tft = Adafruit_ST7735(PIN_TFT_CS, PIN_TFT_DC, PIN_SDA, PIN_SCL, PIN_TFT_RST);
Adafruit_ST7735 tft = Adafruit_ST7735(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST);

The first line (now commented out) works on Uno and Mega2560, but unfortunately is far too slow, the second line is very fast (about 6x) but only works on the Uno, on the Mega2560 the screen remains white and flashes to black and back again once every 7 seconds. Pin connections are exactly same for each board:

#define PIN_TFT_CS 10
#define PIN_SDA 11
#define PIN_SCL 13
#define PIN_TFT_RST 8
#define PIN_TFT_DC 9
(no other pins used in the test)

I need to use the Mega2560 for the extra pins, why can't I get the faster connection working - have I missed something or is there a bug in the library.

Many thanks for any replies

The first constructor will work on both Uno and Mega.
But the second constructor only works with Hardware SPI pin e.g.

#define PIN_TFT_CS 10
#define PIN_SDA 51 //Uno = 11, Mega = 51
#define PIN_SCL 52 //Uno = 13, Mega = 52
#define PIN_TFT_RST 8
#define PIN_TFT_DC 9

Note that the ST7735 is a 3.3V device.

David.

Could be the pins you are using to connect the display on your Mega, might be an idea to post the details ?

Many thanks David, its running like a greyhound now. How bizarre - any idea why???

Compare the two constructors.

The Software SPI constructor has an argument for every pin.
The Hardware constructor omits the MOSI and SCK arguments (because it assumes you are using the Hardware MOSI, SCK pins)

The SW SPI constructor can use any set of random GPIO pins.
The HW SPI constructor must use HW MOSI, SCK but the other arguments can be random GPIO pins.

It is always a good idea to start with the SW SPI constructor. It might be slow but it should work on every Arduino.
This verifies that your screen is working.
Then try the HW SPI constructor. Faster but you must use the correct pins.

David.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.