iwanders / MFRC630

A library for NXP's MFRC630 NFC IC.
MIT License
59 stars 22 forks source link

ISO15693 Support added #13

Open sgtJohnny opened 4 years ago

sgtJohnny commented 4 years ago

I've added basic ISO15693 support to read a tag and output to Serial. Tested on Arduino UNO and CLRC663 Evaluation board.

Please note that ISO15693 only works with CLRC663, which uses same Software as MFRC630, but can read ISO15693, ISO14443B, and many more.

sgtJohnny commented 4 years ago

Added changes you advised, please review

sgtJohnny commented 4 years ago

I will try to fix this as soon as possible and try with timer

ic-twist commented 7 months ago

Posting here too for visibility...

@sgtJohnny Did you or anyone else use NXP's CLEV6630B evaluation board or CLEV6630ARD board for testing and verification of your software?

My hardware setup NXP CLEV6630B eval board connected to Arduino Mega Rev3 through SPI interface.

Software setup Using @sgtJohnny 's iso15693 branch, modified SPI clock rate from 10MHz to 5MHz as shown below. As 10MHz was too fast for my Arduino to drive good SPI signals. SPI.beginTransaction(SPISettings(5000000, MSBFIRST, SPI_MODE0));

Problem Not able to read ISO15693 NFC tags.

What I've Tried

  1. I used a logic analyzer and saw correct bytes (appears to match the firmware) are sending over SPI interface from Arduino Mega to the CLRC663 chip.
  2. I also tried adding the command to turn on RF field in the setup. Please see my setup code below:

    void setup()
    {
    // Start serial communication.
    Serial.begin(9600);
    
    // Set the chip select pin to output.
    pinMode(CHIP_SELECT, OUTPUT);
    digitalWrite(CHIP_SELECT, HIGH);
    
    // Start the SPI bus.
    SPI.begin();
    delay(1000);
    const uint8_t ic_version = mfrc630_read_reg(MFRC630_REG_VERSION);
    Serial.println(ic_version);
    
    // Set the registers of the MFRC630 into the default.
    mfrc630_AN1102_recommended_registers(MFRC630_PROTO_ISO15693_1_OF_4_SSC);
    
    // RF on
    mfrc630_read_reg(MFRC630_REG_DRVMOD);
    mfrc630_write_reg(MFRC630_REG_DRVMOD, 0x89);
    }
  3. I compared the SPI traffic generated by the Arduino code with the SPI traffic generated by the NXP Cockpit GUI software and they don't seem to match up.

My Speculations I'm wondering if the command to read ISO15693 inventory was implemented correctly.

sgtJohnny commented 7 months ago

@ic-twist I remember using a blue board, but not sure if it was CLEV6630B. I've been using the code in a few own designs with the CRLC663 and ISO15693 and never had problems, but I've added a loop to try all ISO15693 settings.

I tried to dig up the board this weekend an try with arduino uno.

ic-twist commented 7 months ago

I fixed the bug in mfrc630_ISO15693_init function that I commented on and it started working for me. Without this change, the registers are not properly loaded. I can make a PR for my changes early next week.

CLEV6630B is also blue so it might be what you used too.

Now that it's working, I noticed that the NFC read range is much smaller (~1cm) when I'm using the arduino as a host micro compared to when I use the LPC micro on the eval board itself and use NXP cockpit GUI to read tags, in which case the range is ~1 inch. Do you know what can improve the read range?

ic-twist commented 7 months ago

Ok - I needed to change some of the register values. The one that made a big difference was MFRC630_REG_RXANA which sets the gain. Also in the process of debugging I realized that I needed to change one of the jumper wires to make sure the CLRC output Vdd is set to 5V. Thanks to this post https://community.nxp.com/t5/NFC/CLRC663-Programming-Guide-via-UART/m-p/664722.

@sgtJohnny The software bug I mentioned is still necessary for this library to work.