I'm having trouble getting the NFC PN532 breakout board and the 2.2" 18-bit color TFT LCD working on the same SPI buss.
From what I understand the Adafruit PN532 arduino library uses software SPI and not hardware SPI? Could this be the problem?
I have tested that the connections are correct. If I disable the Adafruit ILI9340 library the NFC works fine. And if I initialize the NFC library first and then the display then both start.
Code: Select all
Initializing NFC ...
Sending: 0x0 0x0 0xFF 0x2 0xFFFFFFFE 0xD4 0x2 0xFFFFFF2A 0x0
Sending: 0x0 0x0 0xFF 0x2 0xFFFFFFFE 0xD4 0x2 0xFFFFFF2A 0x0
Reading: 0x0 0x0 0xFF 0x0 0xFF 0x0
Reading: 0x0 0xFF 0x6 0xFA 0xD5 0x3 0x32 0x1 0x6 0x7 0xE8 0x0
Found chip PN532
NFC Firmware ver. 1.6
Sending: 0x0 0x0 0xFF 0x5 0xFFFFFFFB 0xD4 0x14 0x1 0x14 0x1 0xFFFFFF02 0x0
Reading: 0x0 0x0 0xFF 0x0 0xFF 0x0
Reading: 0x0 0xFF 0x2 0xFE 0xD5 0x15 0x16 0x0
NFC Ready...
Initializing SD card...OK!
Code: Select all
Sending: 0x0 0x0 0xFF 0x2 0xFFFFFFFE 0xD4 0x2 0xFFFFFF2A 0x0
ERROR!:Didn't find PN53x board! will loop for ever!
Code: Select all
//TFT
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
// TFT display and SD card will share the hardware SPI interface.
// Hardware SPI pins are specific to the Arduino board type and
// cannot be remapped to alternate pins. For Arduino Uno,
// Duemilanove, etc., pin 11 = MOSI, pin 12 = MISO, pin 13 = SCK.
/*
#define _sclk 52
#define _miso 50
#define _mosi 51
#define _cs 53
#define _dc 48
#define _rst 49
#define SD_CS 8
*/
#define TFT_RST 49
#define TFT_DC 48
#define TFT_CS 53
#define SD_CS 8
Adafruit_ILI9340 tft = Adafruit_ILI9340(TFT_CS, TFT_DC, TFT_RST);
//Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);
//RFID
//const int kRfidIrqPin = 6;
//Adafruit_NFCShield_I2C nfc(IRQ, RESET);
//Adafruit_NFCShield_I2C nfc_object(kRfidIrqPin, int(3));
/*
#define SCK (52)
#define MOSI (51)
#define SS (47)
#define MISO (50)
Adafruit_PN532 nfc_object(SCK, MISO, MOSI, SS);
*/
Adafruit_PN532 nfc_object(52, 50, 51, 47);
Code: Select all
// ---------------- Initializing NFC -------------
Serial.println("Initializing NFC ...");
nfc_object.begin();
uint32_t versiondata = nfc_object.getFirmwareVersion();
if (! versiondata) {
Serial.print("ERROR!:Didn't find PN53x board! will loop for ever!");
while (1); // halt
}
// Got ok data, print it out!
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("NFC Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
// configure board to read RFID tags
nfc_object.SAMConfig();
Serial.println("NFC Ready...\n");
// ---------------- Initializing TFT --------------
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS)) {
Serial.println("failed!");
//return;
}
Serial.println("OK!");
tft.begin();
tft.setRotation(3);
tft.fillScreen(ILI9340_WHITE);
//bmpDraw("woof.bmp", 0, 0);
bmpDraw("logo.bmp", 0, 10);
//digitalWrite(kLcdBacklightPin, HIGH);
tft.setTextColor(ILI9340_BLUE);
tft.setTextSize(5);
tft.setCursor(0, 90);
tft.println("Starter...");
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(kLcdBacklightPin, fadeValue);
// wait for 30 milliseconds to see the dimming effect
delay(30);
}