This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TRF7970A: RFID card writing and reading is abnormal

Part Number: TRF7970A
Other Parts Discussed in Thread: DLP-7970ABP, , MSP-EXP430F5529LP, MSP430F5529

1. Purchased TRF7970A and its evaluation board DLP-7970ABP from Digi-Key

2. Created a prototype board equipped with TRF7970A

3. RFID card could be recognized on the prototype board (hexadecimal 20-digit card number)

4. Written data to the memory of the card with this 20-digit card number(I wrote a valid and meaningful hexadecimal 8-digit number)

5. Read data from the card memory with this 20-digit card number(If you check the read data, all are 0x00000000)

6. No error has occurred and I think the data is probably not written or read

------------------- Below terminal display

write 0 Commando line
ID=E0040100A7224E940000 08
adr=0 data=0x53554745 irq_status=E0 uid_length=02 rd=0x0F01
adr=1 data=0x52424F58 irq_status=E0 uid_length=02 rd=0x0F01
adr=2 data=0x20190311 irq_status=E0 uid_length=02 rd=0x0F01
adr=3 data=0x01234567 irq_status=E0 uid_length=02 rd=0x0F01
adr=4 data=0x00000000 irq_status=E0 uid_length=02 rd=0x0F01
adr=5 data=0x00000000 irq_status=E0 uid_length=02 rd=0x0F01
adr=6 data=0xE0070000 irq_status=E0 uid_length=02 rd=0x0F01
adr=7 data=0x168513BD irq_status=E0 uid_length=02 rd=0x0F01
adr=8 data=0xE0070000 irq_status=E0 uid_length=02 rd=0x0F01
adr=9 data=0x16851161 irq_status=E0 uid_length=02 rd=0x0F01
adr=0 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=1 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=2 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=3 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=4 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=5 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=6 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=7 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=8 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
adr=9 irq_status=0xE0 level=0x08 uid_length=0x05 data=0x00000000
trf7970a init...OK.
OK.

------------------- Below the above sources

//////////////////////////////////////////////////////////////////////////////
//rfid reset
//////////////////////////////////////////////////////////////////////////////
void trf7970a_sof_reset(void)
{
int i;
spi_write_byte(CMD_SOFT_INIT)//Soft Init (83h)
spi_write_byte(CMD_IDLE)//Idle (80h)
for(i=0; ;i++){
char data=trf7970a_get(GET_MODULATOR_CONTROL_REG);
if(data==0x91){
break;
}
if(i > 40000){
pc.printf("time out! 0x%02x\r",data);
return;
}
}
wait(1);
}
//////////////////////////////////////////////////////////////////////////////
//rfid reset
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//rfid init
//////////////////////////////////////////////////////////////////////////////
void trf7970a_init(void)
{
unsigned int i;
pc.puts("trf7970a init");
rfid_en1=1;//TRF7970A EN=1
rfid.format(8,1);//spi fomat
rfid.frequency(10000000); //spi osc
rfid_cs=CHIP_SEL_OFF;
rfid.write(0x00);//dummy
pc.putc('.');
trf7970a_sof_reset();//reset
pc.putc('.');
trf7970a_set(0x09,trf7970a_reg09_dat,2);//[Address-W]Modulator and SYS_CLK control
trf7970a_set(0x99,NOND,1);//Test external RF (RSSI at RX input with TX on)
wait(0.001);
rdat[2]=trf7970a_get(0x4F);//[Address-R]RSSI levels and oscillator status
trf7970a_set(0x00,0x21,2);//[Address-W]Chip status control (5V)
trf7970a_set(0x01,0x02,2);//[Address-W]ISO control
trf7970a_set(0x0A,trf7970a_reg0A_dat, 2);//[Address-W]RX special setting
trf7970a_set(0x0B,trf7970a_reg0B_dat, 2);//[Address-W]Regulator and I/O control
trf7970a_set(0x14,0x00,2);//[Address-W]Adjustable FIFO IRQ levels
trf7970a_set(0x18,0x0F,2);//[Address-W]NFC target detection level
rdat[3]=trf7970a_get(0x4C); //[Address-R]IRQ status
pc.putc('.');
for(i=0; i<0x20; i++){
rdat[3]=trf7970a_get(0x40 | i );//[Address-R]IRQ status
}
wait(0.007);
pc.puts("OK.\r");
}
//////////////////////////////////////////////////////////////////////////////
//rfid init
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//rfid CARD ID get
//////////////////////////////////////////////////////////////////////////////
//char *dat <-get data (card no)
//char *level <-rssi level
// ->UID_OK/UID_NG
char trf7970a_ID_get(char *dat, char *level)
{
int k;
rfid_cs=CHIP_SEL_ON;
rfid.write(0x8F);//[Command]Reset FIFO
rfid.write(0x91);//[Command]Transmission with CRC
rfid.write(0x3D);//0011 AWL REG1D_TX_LENGTH_BYTE_1
rfid.write(0x00);//<-0
rfid.write(0x30);//0011 AWL REG00_CHIP_STATUS_CONTROL
rfid.write(0x26);//0010 AWL REG06_TX_PULSE_LENGTH_CONTROL
rfid.write(0x01);//
rfid.write(0x00);//
rfid_cs=CHIP_SEL_OFF;
wait(0.007);
char irq_status=trf7970a_get(0x4C);//[Address-R]IRQ status
if(irq_status !=0xC0){
//pc.printf("%02X",irq_status);
level[0]=0;
trf7970a_set(0x8F,NOND,1);//[Command]Reset FIFO
return(UID_NG);
}
*level=(trf7970a_get(0x4F) & 0x07)+1;//[Address-R]RSSI levels and oscillator status
char uid_length=trf7970a_get(0x5C);//[Address-R]FIFO status
if(uid_length !=UID_LEN){
//pc.printf("%02X",uid_length);
level[0]=0;
trf7970a_set(0x8F,NOND,1);//[Command]Reset FIFO
return(UID_NG);
}
rfid_cs=CHIP_SEL_ON;
rfid.write(0x7F);//[Address-R]FIFO Read Continuous
for(k=0; k<UID_LEN; k++){//@@Read data from FIFO
dat[UID_LEN-k-1]=rfid.write(0x00);
}//@@Read data from FIFO
rfid_cs=CHIP_SEL_OFF;
trf7970a_set(0x8F,NOND,1);//[Command]Reset FIFO
return(UID_OK);
}
//////////////////////////////////////////////////////////////////////////////
//rfid CARD ID get
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//rfid ID write
//////////////////////////////////////////////////////////////////////////////
//char *card <-card no
//char adr <-card adr
//unsigned int dat <-card data
char trf7970a_ID_write_(char *card,char adr,unsigned int dat)
{
trf7970a_set(0x0C,0x0D,2);//Reset Irq Status

char *p=(char*)&dat;
pc.printf("adr=%d data=0x%02X%02X%02X%02X ",adr,p[3],p[2],p[1],p[0]);
rfid_cs=CHIP_SEL_ON;
rfid.write(0x8F);//[Command]Reset FIFO
rfid.write(0x91);//[Command]Transmission with CRC
rfid.write(0x3D);//AWL->1D
rfid.write(0x00);
rfid.write(0xF0);//CRL->10
rfid.write(0x62);//ARL->02
rfid.write(0x21);//AWL->01
rfid.write(card[7]);//card no
rfid.write(card[6]);
rfid.write(card[5]);
rfid.write(card[4]);
rfid.write(card[3]);
rfid.write(card[2]);
rfid.write(card[1]);
rfid.write(card[0]);
rfid.write(adr);//adr 0~9
rfid.write(p[3]);//write data
rfid.write(p[2]);
rfid.write(p[1]);
rfid.write(p[0]);
rfid_cs=CHIP_SEL_OFF;
wait_ms(10);
char irq_status=trf7970a_get(0x4C);//[Address-R]IRQ status
char uid_length=trf7970a_get(0x5C);//[Address-R]FIFO status
pc.printf("irq_status=%02X uid_length=%02X ",irq_status,uid_length);

char rd[2];
if(uid_length==2){
rfid_cs=CHIP_SEL_ON;
rfid.write(0x7F);//[Address-R]FIFO Read Continuous
rd[0]=rfid.write(0x00);//FIFO Read
rd[1]=rfid.write(0x00);//FIFO Read
rfid_cs=CHIP_SEL_OFF;
trf7970a_set(0x8F,NOND,1);//[Command]Reset FIFO
pc.printf("rd=0x%02X%02X ",rd[1],rd[0]);
}

if(irq_status !=0xE0){
disp_irq_status_Error(irq_status);
pc.putc('\r');
return(UID_NG);
}
pc.putc('\r');
return(UID_OK);
}
//////////////////////////////////////////////////////////////////////////////
//rfid ID write
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//rfid ID read
//////////////////////////////////////////////////////////////////////////////
//char *card <-card no
//char adr <-card adr
//unsigned int *dat <-read data
// ->UID_OK/UID_NG
char trf7970a_ID_read_(char *card,char adr,unsigned int *dat)
{
trf7970a_set(0x0C,0x0D,2);//Reset Irq Status

rfid_cs=CHIP_SEL_ON;
rfid.write(0x8F);//[Command]Reset FIFO
rfid.write(0x91);//[Command]Transmission with CRC
rfid.write(0x3D);//AWL->1D
rfid.write(0x00);
rfid.write(0xB0);//CWL->10
rfid.write(0x22);//AWL->02
rfid.write(0x20);//AWL->00
rfid.write(card[7]);//card no
rfid.write(card[6]);
rfid.write(card[5]);
rfid.write(card[4]);
rfid.write(card[3]);
rfid.write(card[2]);
rfid.write(card[1]);
rfid.write(card[0]);
rfid.write(adr);//card adr 0~9
rfid_cs=CHIP_SEL_OFF;
wait_ms(10);
char irq_status=trf7970a_get(0x4C);//[Address-R]IRQ status
char level=( trf7970a_get(0x4F) & 0x07)+1;//[Address-R]RSSI levels and oscillator status
char uid_length=trf7970a_get(0x5C);//[Address-R]FIFO status
pc.printf("adr=%d irq_status=0x%02X ",adr,irq_status);
pc.printf("level=0x%02X ",level);
pc.printf("uid_length=0x%02X ",uid_length);
if(uid_length==5){
rfid_cs=CHIP_SEL_ON;
rfid.write(0x7F);//[Address-R]FIFO Read Continuous
char *p=(char*)dat;
p[0]=rfid.write(0x00);//FIFO Read
p[0]=rfid.write(0x00);//FIFO Read
p[1]=rfid.write(0x00);//FIFO Read
p[2]=rfid.write(0x00);//FIFO Read
p[3]=rfid.write(0x00);//FIFO Read
rfid_cs=CHIP_SEL_OFF;
trf7970a_set(0x8F,NOND,1);//[Command]Reset FIFO
if(irq_status==0xE0){
pc.printf("data=0x%02X%02X%02X%02X\r",p[3],p[2],p[1],p[0]);
return(UID_OK);
}
}
pc.putc('\r');
disp_irq_status_Error(irq_status);
return(UID_NG);
}
//////////////////////////////////////////////////////////////////////////////
//rfid ID read
//////////////////////////////////////////////////////////////////////////////

------------------- Above source so far

The DLP-7970ABP evaluation board is out of order and cannot work.
I would appreciate it if you could point out any inconveniences in the above source settings.

  • Hello,

    even though I would like to help you in this case I have to say that debugging customer code is beyond the support that we can give.

    You have written it is unclear if the data is not written or not read correctly. Is it possible for you to check with a NFC enabled smartphone the content of the memory blocks to check if the problem is read or write related?

    What sort of RFID card with which standard are you using?

    Best regards,

    Helfried

  • Helfried
    Thank you

    >You have written it is unclear if the data is not written or not read correctly. Is it possible for you to check with a NFC enabled smartphone the content of the >memory blocks to check if the problem is read or write related?

    I don't know how to do it

    >What sort of RFID card with which standard are you using?

    www.iccard.net/.../card_icode.html

    I'm using I-CODE SLI (ISO15693)

  • Hello,

    I am using an Android smartphone with the App "NFC TagInfo" but I think there a more Apps around that can do the job on an Android Mobile.

    ISO15693 is not a problem and works well with the TRF7970A. One thing that comes into my mind, is, if you have checked if you are using the right block-size (4/8 byte) when reading/writing blocks.

    Best regards,

    Helfried

  • Hello,

    >I am using an Android smartphone with the App "NFC TagInfo" but I think there a more Apps around that can do the job on an Android Mobile.

    How does this help?

    >ISO15693 is not a problem and works well with the TRF7970A. One thing that comes into my mind, is, if you have checked if you are using the right block-size (4/8 byte) when reading/writing blocks.

    Which register should the correct block size (4/8 bytes) be set to?

    Is there any material that is most suitable for this case?

    Thank you

  • Mr.Helfried

    How should I set the block size (4/8 bytes) when reading / writing a block?
    rfid.write (0x3D);
    rfid.write (0x00);
    rfid.write (0x04);
    I have made various thoughts and mistakes, but it seems that I can not set it well

    // WRITE TO LENGTH REG
    SPI_SendByte(0x3D);

    if(broken_bits == 0x00){
    // LENGTH HIGH Nibble
    SPI_SendByte(ui8LenHigherNibble); // Previous data to TX, RX

    // LENGTH LOW Nibble
    SPI_SendByte(ui8LenLowerNibble); // Previous data to TX, RX

    }else{

    // Broken Bit
    SPI_SendByte(0x00);
    SPI_SendByte((broken_bits << 0x01) | 0x01);
    }

    Broken Bit
    I don't understand the meaning of
    What does this mean?

  • Hello,

    the "Broken Byte" handling is needed when you want to transmit data that is not modulo 8. Because in the TX_Length register are only the number of bytes to transmit specified. If you have to transmit, lets say, 27 bits, you have 3 bytes TX_Length plus 3 bits in the Broken Byte to set.

    I took a closer look to your and how you read the UID. What ISO15693 command are you using to read the UID? I was not able to understand how this is done. Are you able to read the UID with this code?

    Best regards,

    Helfried

      

  • Mr.Helfried

    >I took a closer look to your and how you read the UID. What ISO15693 command are you using to read the UID? I was not able to understand how this is done. Are you able to read the UID with this code?

    The UID is read by trf7970a_ID_get.

    You can read 20 hexadecimal values for each card
    You can also read RSSI levels from 0 to 7.

    For example

    ID=E0040100A7224E940000 00
    ID=E0040100A72206000000 00

    And so on
    I think this is a success.

    Isn't this ID the UID?

    I'm not sure about the ISO15693 command

    >ISO15693 is not a problem and works well with the TRF7970A. One thing that comes into my mind, is, if you have checked if you are using the right block-size (4/8 byte) when reading/writing blocks.

    To find out this

    The evaluation boards I purchased are DLP-7970ABP and MSP430F5529LP.

    I installed TRF7970A-RW-1.03.00-windows-installer.exe

     C: \ ti \ nfc \ TRF7970A_RW_1.03.00 \ examples \ boards \ MSP-EXP430F5529LP \ F5529LP_TRF7970A_ALL_NFC_MODES

    Trying to find the answer from

    Please tell me how to set block-size (4/8 byte)

    I understand Broken Byte

    https://code.woboq.org/linux/linux/drivers/nfc/trf7970a.c.html

    Studying

    Best regards,

  • Hello

    I figured out how you are able to read the UID. I noticed that the comments are completely wrong.

    This is the part in your code where the ISO15693 command is loaded to read the UID:

    rfid.write(0x3D);//0011 AWL REG1D_TX_LENGTH_BYTE_1
    rfid.write(0x00);//<-0
    rfid.write(0x30);//0011 AWL REG00_CHIP_STATUS_CONTROL
    rfid.write(0x26);//0010 AWL REG06_TX_PULSE_LENGTH_CONTROL
    rfid.write(0x01);//
    rfid.write(0x00);//

    I will explain here the correct meaning. This code will send the ISO15693 command "Inventory"

    rfid.write(0x3D);// write register address 0x1D with the continuous address bit set to write data to subsequent register addresses
    rfid.write(0x00);// data for register 0x1D TX Length Byte1 -> 0x00
    rfid.write(0x30);// data for register 0x1E TX Length Byte2 -> 0x30 (length of data to transmit is 3 bytes)
    rfid.write(0x26);// data for register 0x1F FIFO -> 0x26 (this is the flag byte of the ISO15693 command - inventory bit is set; high data rate; single subcarrier)
    rfid.write(0x01);// data for register 0x1F FIFO -> 0x01 ( this is the ISO15693 command Inventory)
    rfid.write(0x00);// data for register 0x1F FIFO -> 0x00 (this is the mask length for the ISO15693 Inventory command)

    Due to the fact that the continuous address bit is set in the first command the subsequent writes will go to the next register address. Writes to the FIFO will fill the FIFO and will always be at the same address (0x1F).

    The UID you receive is 64bit number (16 digits).

    Please get confident with the ISO15693 standard this is the only way to understand how to read from, or write to your tag. I am not able to give further support here. I don't know where your code comes from but you should stay with the code examples from our website.

    Best regards,

    Helfried

     

  • Helfried

    Hello

    Thank you for explaining the correct meaning

    I thought it was a failure at first, but when I tried to operate it, there was no problem.

    Attempt to operate the set of evaluation board DLP-7970ABP and MSP430F5529

    Translated and confirmed the English manual slou452.pdf of this evaluation board

    Evaluation board PC software TI NFC Tool installed

    Initially 13.56MHz radio wave is not observed.

    The UID is 0xE0040100A7224E94 with 16 digits

    The card number is wrong, such as E0040100A72206000000 or E0040100A7224E940000.

    It was pointed out that it is 64-bit 8-byte 16-digit.

    Evaluation board is MSP-EXP430F5529LP

    Would you please create the source in a way that does not use interrupts?

    I don't know how to divert the source because I'm using interrupts

    What's wrong with the source in <char trf7970a_ID_get (char * dat, char * level)>?

    Can you give me some good tips if you can?

    Is the NFC / HF RFID Reader / Writer Using the TRF7970A document correct in sloa227b.pdf?

  • Hello,

    what I see from your screenshots you have the bundle of TRF7970ABP and EXP430F5529LP up and running with the NFC software.

    You wrote the card number is wrong but what I see it is the same as the UID in the screenshot just with added '0000' which can be removed.

    Why do you think with the source in <char trf7970a_ID_get (char * dat, char * level)> is something wrong. You are reading the correct UID.

    As far as I know is the document sloa227b.pdf correct. Have you found something that makes you think it is wrong?

    Best regards,

    Helfried

  • Helfried

    Hello

    I'm not saying that the sloa227b.pdf documentation is wrong

    When reading a card with the source of <char trf7970a_ID_get (char * dat, char * level)>, it is wrong to have 20 digits like E0040100A72206000000 and E0040100A7224E940000, and I am saying how to read with 16 digits.

  • If this is all right, you don't need to consult

    Can't you give a clear answer?

    One thing that comes into my mind, is, if you have checked if you are using the right block-size (4/8 byte) when reading/writing blocks.

    Is there no answer for this?

  • Hello,

    ISO15693 tags can have different memory size and different memory block sizes. When using the "Get System Information" command (0x2B) you will receive memory size information. This information contains info about memory size and block size of the tag. This command is not mandatory regarding the ISO15693 standard but normally implemented.

    When using the "Write Single Block" command you have to handle the block- size correct (number of data bytes in the command) and also when reading data with the "Read Single Block" command you have to take the block size in account when decoding your data.

    In your case, when using only one specific tag with known memory size and block size this is not necessary.

    Best regards,

    Helfried

  • Helfried

    Hello,

    I don't know if the source I presented first is wrong or correct

    When I try to use it, 0 is read as I raised

    The sample source of the evaluation board uses IRQ, but in this case I do not use it so I can not simply compare the sources and see by all means

    I was thinking about analyzing the source of the evaluation board

    I haven't solved the problem yet

    I will end here

    It was a mistake to simply think that the source was wrong or that you could see an example.

    I don't understand English at all, so maybe I said something rude, but please forgive me

    that's all, thank you very much.