Hello,
I'm not a pure newby, but still beginner.
I'm struggeling with chipSelect of 2 boards using SPI (2 slave boards, arduino as master).
My goal is to display a bmp-file on the display, which is stored on the mSD-Card.
My boards/configuration:
- Arduino 2560 MEGA
- Adafruit RA8875 TFT driver board
- TFT display 4,3" (480x272) (from Adafruit shop)
- mSD-Breakout Board from watterott.de
- Arduino IDE 1.0.5
- Librarys:
Adafruit_RA8875 (provided by Adafruit, downloaded at GitHub)
Adafruit_GFX (provided by Adafruit, downloaded at GitHub)
I've wired the RA8875 to MEGA2560 as follows:
RA8875 MEGA
MISO 50
MOSI 51
SCK 52
INT 3
RST 9
CS 10
(As described in example sketch)
After first failed try and hours of internet research I've downloaded the Adafruit_GFX files (.cpp & .h) and placed them into the library.
Playing around with example sketch "textmode" the display works fine and shows the "Hello World" text.
Now wiring the mSD-board to MEGA 2560 board as follows AND disconnecting RA8875 from MEGA2560
mSD MEGA
DO (MISO) 50
DI (MOSI) 51
CLK 52
CS 6
With basic example sketch "CardInfo" of SD-library I get access to the mSD (it is a SDHC card).
Long way to this point, but I think I give to much information than to little.
NOW the problem:
Connecting both boards (RA8875 and mSD) and upload 'textmode' sketch, the display doesn't work. Disconnect mSD-Board -> display works.
OK, the cs of SD-Board (SD_cs) interfers with the display.
I brought parts of the 'SD' sketch into the 'textmode' sketch, and setting the SD_cs to HIGH and RA8875_CS to LOW, the display works.
Now set RA8875_CS to HIGH and SD_cs to LOW -> mSD is not working.
Here my sketch in the stage of having both boards connected and trying to use the SD card.
/******************************************************************
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"
#include <SD.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
Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;
int SD_cs = 6;
void setup()
{
pinMode(RA8875_CS, OUTPUT);
pinMode(SD_cs, OUTPUT);
digitalWrite(RA8875_CS, LOW);
digitalWrite(SD_cs, HIGH);
Serial.begin(9600);
Serial.println("RA8875 start");
/* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
if (!tft.begin(RA8875_480x272)) {
Serial.println("RA8875 Not Found!");
// while (1);
}
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);
tft.fillScreen(RA8875_BLACK);
/* Switch to text mode */
tft.textMode();
/* Render some text! */
char string[15] = "Hello WORLD! ";
tft.textTransparent(RA8875_RED);
tft.textWrite(string);
tft.textSetCursor(100, 150);
tft.textEnlarge(2);
tft.textWrite(string);
Serial.print("Initializing SD card...");
if (!SD.begin(SD_cs)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
}
void loop()
{
}
Even I just use the default 'textmode' sketch (no mSD-board connected) and trying to set RA8875_CS to HIGH, the display is still working.
How can I turn the RA8875 to a mode I can address other SPI devices?
Thank you very much.