I have a Strange problem using SPI communication between ESP8266 (Wemos D1 mini R2) and a NFC card (BM019).
(I'm using Arduino IDE on Windows 10) with es8266 version 2.5.2 installed
SPI initialisation is Ok (and the setting of BM019 for NFC protocol is OK)
All data sent by Master (ESP8266) are correctly received by slave
But when I ask data from slave, the first bit is lost and all received data are shifted left one bit (???)
SPI init :
const int SSPin = 15; // Slave Select pin
const int IRQPin = 16; // Sends wake-up pulse for BM019
const int MOSIPin = 13;
const int SCKPin = 14;
void setup() {
...
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV128);
SPI.begin();
…
digitalWrite(SSPin, LOW);
SPI.transfer(0x00); // SPI control byte to send command to CR95HF
SPI.transfer(0x02); // Set protocol command
SPI.transfer(0x02); // length of data to follow
SPI.transfer(0x01); // code for ISO/IEC 15693
SPI.transfer(0x0D); // Wait for SOF, 10% modulation, append CRC
digitalWrite(SSPin, HIGH);
}
And later in the code (for example Inventory command or read data from an NFC tag, all data are shifted one bit left and most significant bit is lost... (I have verified with a logic analyser that data sent by Slave are Ok) :
...
digitalWrite(SSPin, LOW);
SPI.transfer(0x02); // SPI control byte for read
RXBuffer[0] = SPI.transfer(0); // response code sent (Logic Analizer) 0x80 but RXBuffer[0]=0
RXBuffer[1] = SPI.transfer(0); // length of data sent (Logic Analizer) 0x0D but RXBuffer[1]=0x1A
digitalWrite(SSPin, HIGH);
I tried with an ESP32 (MH-et-LIVE) but I have the same Issue...
Can someone help me to solve this problem ?
Thanks