ST RFID sensor doesn't respond to Arduino Due

Dear any-one who is familiar in this subject,

I am trying to drive the ST25RU3993 Eval board using SPI, with my Arduino Due (both devices run on 3.3V) to prototype a quick project. I use the oscilloscope and it seems my spi outputs (sclk, mosi, chipselect, enable) is working. However my ST25 board is not responding at all.

Any clue?

here is the datasheet for ST25RU3993 with its register information:
https://www.st.com/resource/en/datasheet/st25ru3993.pdf

here is my Arduino code:

#include <SPI.h>
////////////////////////////////////////////
//set up pins for arudino due
//MOSI:ICSP-4
//MISO:ICSP-1
//SCK:ICSP-3
//NCS:52
//EN:2
//
///////////////////////////////////////////////

// Set up chip-select pin as NCS and enable pin as EN
const int NCS = 52;
const int EN = 2;

//SPI setting
SPISettings settingsA(2000000, LSBFIRST, SPI_MODE1);

void setup() {

  pinMode (NCS, OUTPUT);
  pinMode(EN, OUTPUT);
  digitalWrite(EN, HIGH);//set enable to high

  SPI.begin();
  //  SPI.beginTransaction(settingsA); //I wrote to the following 2 main control registers, register description is at the data sheet

  digitalWrite (NCS, LOW);
  SPI.transfer(0b00000000); // write and register addressL: Device staus register
  SPI.transfer(0b00000001); // value for this register: Turn RF-On
  digitalWrite (NCS, HIGH);

  digitalWrite (NCS, LOW);
  SPI.transfer(0b00000001); // write and register addressL: Protocal Selection Register
  SPI.transfer(0b00000000); // value for this register: Choose EPC Gen2
  digitalWrite (NCS, HIGH);

  // SPI.endTransaction();
}



void loop() {
  //
  for (int i = 0; i <= 255; i++) {

    //  SPI.beginTransaction(settingsA); //read from my RSSI_Display register
    digitalWrite (NCS, LOW);

    SPI.transfer(0b00101011);

    digitalWrite (NCS, HIGH);
    // SPI.endTransaction();

  }
}

attack are the photo of my set up.

Thanks in advance

You need to re-enable begin/endTransaction to ensure you are using the right settings, which I believe to be 5000000 (max), MSBFIRST, SPI_MODE1.
If you are trying to read from the RSSI register then SPI.transfer(0b00101011) should be SPI.transfer(0b01101011) .

I would also consider powering the eval board over the USB port, at least until you get things working.

Thank you for your respond arduarn,

powering with USB port indeed turned the RFID board on, at least the PLL is running (PLL light was on the board)

and so I put the rate up to 5M, but I still don't get to read anything useful. Here is my modified version

#include <SPI.h>
////////////////////////////////////////////
//set up pins for arudino due
//MOSI:ICSP-4
//MISO:ICSP-1
//SCK:ICSP-3
//NCS:52
//en:2
//
///////////////////////////////////////////////

const int NCS = 52;

// set up the speed, data order and data mode
SPISettings settingsA(5000000, MSBFIRST, SPI_MODE1);

void setup() {

  pinMode (NCS, OUTPUT);
  pinMode(2, OUTPUT);
  digitalWrite(2, HIGH);
  Serial.begin(9600);
  runonce(); // wirte my register only once
}


void runonce() {
  SPI.begin();
  SPI.beginTransaction(settingsA); //I wrote to the following 2 main control registers, register description is at the data sheet

  digitalWrite (NCS, LOW);
  SPI.transfer(0b00000000); // write and register addressL: Device staus register
  SPI.transfer(0b00000001); // value for this register: Turn RF-On
  digitalWrite (NCS, HIGH);

  digitalWrite (NCS, LOW);
  SPI.transfer(0b00000001); // write and register addressL: Protocal Selection Register
  SPI.transfer(0b00000000); // value for this register: Choose EPC Gen2
  digitalWrite (NCS, HIGH);

  SPI.endTransaction();
  Serial.print("written");
}

int8_t Q ;
void loop() {

  for (int i = 0; i <= 5000; i++) {

    digitalWrite (NCS, LOW);
    Q =  SPI.transfer(0b01101011);
    digitalWrite (NCS, HIGH);

  }

  Serial.print(Q);  // see it at serial monitor
}

like before checking with oscilloscope, the MOSI and SCLK looks good. MISO when probed gave square wave like signal but with only 100mV amplitude.
the serial monitor keeps outputting 75 with or without any tag presented or not.

I also put in a few other register addresses to read, getting back the same serial reading.

this board is getting quite confusing to me as why wouldn't it work..... :o :frowning:

fghsfghsrthgt:
MISO when probed gave square wave like signal but with only 100mV amplitude.

Interesting...
If haven't already, try probing directly on the Eval board with the MISO disconnected from the Due.

that was indeed the way i probe. btw when using the demo gui (which the eval board is successfully reading tags) all the led lights are quite bright while i my case it was dimmed. not sure i even turned the IC on or not ( EN is providing 3.3 V and it is also powered through USB)

That is odd with the LEDs. If I understood the documentation right, you should have enough power to operate the board even with just the 3.3V, albeit at a lower power shorter range. But better to supply all the power to eliminate at this stage.

Looking at the eval board document it says "SPI mode 1 (4 MHz)", which contradicts what I previously read. Better wind that down a bit, maybe to your original 2MHz.

With just the CLK connected what does the output on the MOSI pin look like with the MOSI wire disconnected and probing on the eval board?

Pulling this out of my rear, but maybe try a 10k pull-up on MISO - though it really shouldn't be necessary.

EDIT:
Even more ridiculous, try holding down the MCU reset button on the eval board when testing. It is also connected to the SPI pins, so maybe could interfere? Reset may of course reset the RFID chip too though...

I am able to read high/low probing the MOSI pin and it does match up to what i typed in the code.

another simple question.... so i was probing the reset pin out of the spi on arduino due, should it suppose to be high (3.3V)? i am quite new to spi

the reset is not connecting to anything though i don't think that matters...

I would expect it to be the usual active low (so high when not in reset). The reset pin has nothing to do with SPI in particular, it is just passed through on the header to allow all attached hardware to be reset when the Arduino is reset.

i think i might find the problem.... have to test it though.

so arduino does idle high on MOSI pins on all 4 SPI modes, while strange enough, the st electronics use idle low for MOSI when I probe it.....

fghsfghsrthgt:
so arduino does idle high on MOSI pins on all 4 SPI modes, while strange enough, the st electronics use idle low for MOSI when I probe it.....

The SPI modes have more to do with the SCK signal. I'm no SPI expert, but I don't think MOSI has a particular idle state, the state is only valid when clocked so the slaves will otherwise ignore both a high and low level. I think MISO should be high-impedance in idle to avoid conflicts with the other slaves.

I also found this: Solved: ST25RU3993 - reading registers - STMicroelectronics Community, but rather unhelpfully there isn't a clear answer in it and the poster didn't seem to be using the eval board anyway. Definitely worth reviewing all your connections again though.

thanks for the help arduarn,

i got to read the register successfully.
the problem was not the idle low/high.

for anyone who might find this useful
so arduino spi has 1us delay for consecutive byte sending, during this time the sclk is put back to idle. that translates into: arduino spi can only work on SLOW clock rate, anything faster than 1MHz is going to corrupt. I put my clock down to 100k and it works now.

fghsfghsrthgt:
for anyone who might find this useful
so arduino spi has 1us delay for consecutive byte sending, during this time the sclk is put back to idle. that translates into: arduino spi can only work on SLOW clock rate, anything faster than 1MHz is going to corrupt. I put my clock down to 100k and it works now.

Glad you've made some progress, but I don't find your explanation satisfactory.

A 1us "idle" clock isn't going to make any difference since SPI operates on clock transitions.
You also scoped out MOSI & SCK in post #2 and they looked good. The problem was a low amplitude signal on the MISO, which is driven by the slave, ie. the ST25RU3993. So, if anything, it would suggest that the ST25RU3993 can't handle the speed (which I doubt).

Anyway, I don't know the answer, but if you have it working to your satisfaction then I'm happy too. :slight_smile:

you are right, its that the sensor chip take the first 8 bit and immediately as register address and then immediately gives output-- so this requires non stoppable clock for 16 bit operation ( 16 clock cycles).

what happens when we set the clock too fast (1 clock cyc < 1us) is that we will have 8 cycles of clock -- clock down -- 8 cycles of clock. for which we are not going to be able to read anything.

so when i turn the clock way down (1 clock cyc >1us) we will have 8 cycles of clock --comparably small delay of 1us -- 8 cycles of clock, which it successfully reads.

ps, the small amplitude i probed was the coupling from the mosi pin.

i hope this is a clearer explanation.