Skip to main content
Visitor II
June 21, 2018
Solved

M24Sr02 Read and Write Problem(I2C)

  • June 21, 2018
  • 2 replies
  • 3194 views
Posted on June 21, 2018 at 20:37

Hello Everyone!

I am currently using the dynmaic nfc tag M24SR02-Y and I am facing problems with it while communicating with I2C. I get all the correct responses but when i try to read the NDEF length something goes wrong. I would appreciate if someone could help me out with this issue, I have been coding it for 2 days now and nothing seems to work.

Here are my commands with Responses:

//Send 'Kill RF and open I2C

  Send AC 52

  //Select NFC-T4

  AC 02 00 A4 04 00 07 D2 76 00 00 85 01 01 00 CRC CRC

  //Read back answer from M24SR

  Write AD, READ 02 90 00 CRC CRC

  // select CC

  AC 03 00 A4 00 0C 02 E1 03 CRC CRC

  //Read back answer from M24SR

  Write AD Read 03 90 00 CRC CRC

  //Read CC file-length

  AC 02 00 B0 00 00 02 CRC CRC

  //Read back answer from M24SR

  Write AD Read 02 00 0F 90 00 CRC CRC

  //Read CC file

  AC 03 00 B0 00 00 0F CRC CRC

  //Read back answer from M24SR

  Write AD Read 03 00 0F 20 00 F6 00 F6 04 06 00 01 01 00 00 00 90 00 CRC CRC

Write commands

 

//Select NDEF file

 

  AC 02 00 A4 00 0C 02 00 01 CRC CRC

 

 

  Write AD Read 02 90 00 CRC CRC

 

 

 

 

 

  //Erase NDEF message length

 

  AC 02 00 A4 00 0C 02 00 01 CRC CRC

 

 

  Write AD Read 03 90 00

 

 

 

 

  //Write NDEF message

Wrote AC 02 00 D6 00 02 0D D1 01 09 54 02 65 6E 4E 69 63 6B 65 21 21 CRC CRC

Read 03 09 00 CRC CRC

//Write NDEF length

AC 03 00 D6 00 00 02 00 0E CRC CRC

  Write AD Read 02 90 00 CRC CRC

//Deselect command

AC C2 CRC CRC

when i remove supply and place my phone on top of the antenna the tag reads 0 bytes/255. What am I doing wrong?

:(

To verify the write was successful I added  read commands as well.

Read Commands

//Select NDEF file

  AC 02 00 A4 00 0C 02 00 01 CRC CRC

  //Read back answer from M24SR

  Write AD Read 02 90 00 CRC CRC

  //Read NDEF message length

  AC 03 00 B0 00 00 02 CRC CRC

  Write AD Read 03 00 0f 90 00 44 45 Similar to the response of CC file length but length shows '0x0f' whereas written is 0E 

and when I try to read the data it is similar to contents of CC file. Please help me.

Thanks in advance.

#i2c-isues #m24sr #nfc-tags #m24sr-i2c
    This topic has been closed for replies.
    Best answer by Rene Lenerve
    Posted on June 22, 2018 at 17:16

    Hi Anish,

    Looking into your m24sr.txt file, one thing I noticed that makes an error, when trying to reproduce your sequence, is the length of data in function testWrite and writeNDEFLength. The length of your NDEF is 14 bytes, so you should set the length to 0x0E (and

    therefore change the CRC also).

    Here after are the fixed functions:

    void testWrite(void){
     
     I2CStart();
     I2CSlaveAddress(M24SR_I2C_ADDR);
     I2CWriteSingle(0x02);
     I2CWriteSingle(0x00);
     I2CWriteSingle(0xD6);
     I2CWriteSingle(0x00);
     I2CWriteSingle(0x02);
     I2CWriteSingle(0x0E);//fixed size value
     I2CWriteSingle(0xD1);
     I2CWriteSingle(0x01);
     I2CWriteSingle(0x09);
     I2CWriteSingle(0x54);
     I2CWriteSingle(0x02);
     I2CWriteSingle(0x65);
     I2CWriteSingle(0x6E);
     I2CWriteSingle(0x4E);
     I2CWriteSingle(0x69);
     I2CWriteSingle(0x63);
     I2CWriteSingle(0x6B);
     I2CWriteSingle(0x65);
     I2CWriteSingle(0x21);
     I2CWriteSingle(0x21);
     I2CWriteSingle(0x21);//updated CRC value
     I2CWriteSingle(0x9D);//updated CRC value
     I2CStop();
     __delay_ms(1000);
     ReceiveResponse(1);
    }
    void writeNDEFLength(void){
     
     I2CStart();
     I2CSlaveAddress(M24SR_I2C_ADDR);
     I2CWriteSingle(0x03);
     I2CWriteSingle(0x00);
     I2CWriteSingle(0xD6);
     I2CWriteSingle(0x00);
     I2CWriteSingle(0x00);
     I2CWriteSingle(0x02);
     I2CWriteSingle(0x00);
     I2CWriteSingle(0x0E);//fixed size value
     I2CWriteSingle(0x15);//updated CRC value
     I2CWriteSingle(0xDE);//updated CRC value
     I2CStop();
     __delay_ms(10);
     ReceiveResponse(1);
     
    }
    �?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

    Hope this can help you.

    Regards.

    2 replies

    Technical Moderator
    June 22, 2018
    Posted on June 22, 2018 at 09:14

    Hello Anish,

    First of all thanks for your interest in M24SR02 product !

    Then, I can see two reasons explaining the misbehaviour :

    when you try to erase the NDEF length :

     

    //Erase NDEF message length

      AC 02 00 A4 00 0C 02 00 01 CRC CRC

     

    -> in fact you redo a select ndef file

    can you please replace this command by : AC 02 00 D6 00 00 02 00 00 CRC CRC ?

    Then when you rewrite the ndef length you progamm 00 0E but you have written 0D data in the previous command . Could you try the rewrite the ndef length to 00 0D instead ?

    Hope this helps,

    Best Regards,

    BB

    Visitor II
    June 22, 2018
    Posted on June 22, 2018 at 11:46

    Thank you for the reply! The erase data command that I wrote in the code had D6 it's a typo error. Also could you please tell me the exact setting for GPO pin as I have just added a 10k pull-up resistor to it. Do I have to send some specific commands for it?

    ThabTh

    Technical Moderator
    June 22, 2018
    Posted on June 22, 2018 at 13:48

    Hello Anish,

    To program the GPO you have to program the address 0x0004 of the system file depending on which event you want to observe.

    Please refer to chapter 2.7 and 3.1.4 of the datasheet at the link below :

    https://www.st.com/content/st_com/en/products/nfc/st25-nfc-rfid-tags-readers/st25-dynamic-nfc-tags/m24sr-series-dynamic-nfc-tags.html?querycriteria=productId=SS1812

     

    Hope this helps,

    Best Regards,

    BB

    Visitor II
    June 25, 2018
    Posted on June 25, 2018 at 18:38

    Thank you all for helping me with this issue. I have figured out why there was no data. The issue has been resolved and it was due to the length of the data that i was inserting in the readNDEFData command. Also, before selecting the NDEF file we need to send NDEFTagApllciation command for successful reading of NDEF file length. I will be posting my working commands for those might face problem.

    Thank you once again especially to

    Brochier.Beatrice

    ‌ and

    Lemonnier.Renaud

    ‌.