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.

Driver consistently read the rssi register as 0x40

Other Parts Discussed in Thread: TRF7970A

Hi,

    I can correctly write and read the trf7970's registers when seeing in oscilloscope.

    I removed the my test code in trf7970.c and only added printk in trf7970a_read function(below). When I run the poll with neard application,I was seeing     0x40 value in 0x0f address. NFC tag closer to antenna does not change anything. Driver consistently read 0x0f address( rssi register) and this register value 0x40. What is the reason of this situation?


    static int trf7970a_read(struct trf7970a *trf, u8 reg, u8 *val)
    {
    u8 addr = TRF7970A_CMD_BIT_RW | reg;
    int ret;

    ret = spi_write_then_read(trf->spi, &addr, 1, val, 1);
    if (ret)
    dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n", __func__, addr,
    ret);

    printk(KERN_INFO" reading adress: 0x%02x data: 0x%02x \n",reg,*val);

    dev_dbg(trf->dev, "read(0x%x): 0x%x\n", addr, *val);

    return ret;
    }

  • Hello,

    The RSSI Register will only update when it receives a reply from a tag. Just placing the tag in the RF field at varying distances will not update the RSSI register value. The RSSI register will update it's value when receiving a reply from the tag as it uses the strength of the load modulation from RFID tags reply to a command in order to determine the strength of connection with the RFID tag and generate a new RSSI value.
  • Hi,

    Thank you,

    My nfc tags can reply the NFC Tools application in android. In other words, there is a not problem in nfc tags.
    But, antenna of trf7970 can't give the signal from nfc tags. Therefore , rssi register does not update itself. In
    this situation, I think that this problem is related to setting of trf7970 pins or its power. Is it wrong? Otherwise,
    Is there a problem in trf7970.c or neard application?

    Best Regards,
  • Hello,

    Are you issuing any NFC commands in order to communicate to the NFC tag prior to calling the function trf7970a_read?

    I had no doubt that the NFC tags are working fine. However, if you do not issue an NFC command which the NFC tag will reply to BEFORE checking the RSSI register, it will not be able to update it.

    Can you describe the flow of commands you are using (such as part configuration, read tag, read RSSI register etc.)? Are you using an example application as-is with only adding the printk line, or are you running your own sequence of commands?

  •  Hi,

        I only added the printk in trf7970.c.(read , write and cmd function) I did not change anything in code.


    static int trf7970a_cmd(struct trf7970a *trf, u8 opcode)
    {
        u8 cmd = TRF7970A_CMD_BIT_CTRL | TRF7970A_CMD_BIT_OPCODE(opcode);
        int ret;

        dev_dbg(trf->dev, "cmd: 0x%x\n", cmd);

        ret = spi_write(trf->spi, &cmd, 1);

        printk(KERN_INFO" opcode : 0x%02x  \n",opcode);

        if (ret)
            dev_err(trf->dev, "%s - cmd: 0x%x, ret: %d\n", __func__, cmd,
                    ret);
        return ret;
    }

    static int trf7970a_read(struct trf7970a *trf, u8 reg, u8 *val)
    {
        u8 addr = TRF7970A_CMD_BIT_RW | reg;
        int ret;

        ret = spi_write_then_read(trf->spi, &addr, 1, val, 1);
        if (ret)
            dev_err(trf->dev, "%s - addr: 0x%x, ret: %d\n", __func__, addr,
                    ret);

        printk(KERN_INFO" reading  adress: 0x%02x data: 0x%02x  \n",reg,*val);


        dev_dbg(trf->dev, "read(0x%x): 0x%x\n", addr, *val);

        return ret;
    }
    static int trf7970a_write(struct trf7970a *trf, u8 reg, u8 val)
    {
        u8 buf[2] = { reg, val };
        int ret;

        dev_dbg(trf->dev, "write(0x%x): 0x%x\n", reg, val);

        ret = spi_write(trf->spi, buf, 2);

        printk(KERN_INFO" writing  adress: 0x%02x data: 0x%02x  \n",reg,val);
        if (ret)
            dev_err(trf->dev, "%s - write: 0x%x 0x%x, ret: %d\n", __func__,
                    buf[0], buf[1], ret);

        return ret;
    }

    I am observing the sequence that is below.

        writing  adress: 0x00 data: 0x01  
        writing  adress: 0x01 data: 0x88  
         writing  adress: 0x09 data: 0x01  
        writing  adress: 0x00 data: 0x21
        opcode : 0x0f
        writing  adress: 0x00 data: 0x01  
        cmd  opcode : 0x03  
        cmd  opcode : 0x00   
        writing  adress: 0x09 data: 0x00  
        writing  adress: 0x14 data: 0x0f  
        writing  adress: 0x10 data: 0x00  
        writing  adress: 0x18 data: 0x00  
        writing  adress: 0x00 data: 0x03  
        cmd  opcode : 0x19   
        reading  adress: 0x0f data: 0x40

     I am using neard as user space application.(www.ti.com/.../sloa210.pdf) My terminal command is;

        ./neard
        test/test-adapter powered nfc0 on
        test/test-adapter poll nfc0 on
        test/test-tag list

    Is there a problem in command sequence? Do you know user space application for trf7970 that is different neard ?

    best regards.

  • Hi

    Now that u are confirmed that writing and reading are working fine,remove the debug printk which you have applied in the driver as trf7970a is a time sensitive device.
    Can you check whether you are getting interrupts of Tx complete and Rx recieved ?
    U can apply one printk in trf7970a_irq() to check this.
    Also which type of tags you are using?
    Regarding neard u can enable debug in neard and run the daemon in background to understand the scenario by the following command:
    neard -n -d "*" &

    Thanks
  • Hi,

    My nfc tags are using the ISO-15693 protocol. I removed all of printk functions in the trf7970.c.
    Then, I applied one printk in trf7970a_irq() that is below.

    ret = trf7970a_read_irqstatus(trf, &status);
    if (ret) {
    mutex_unlock(&trf->lock);
    return IRQ_NONE;
    }
    printk(KERN_INFO"IRQ - state: %d, status: 0x%x\n", trf->state,status);


    I am seeing the state is 5 and status is 0x80. What does this mean? I can not understand these values in
    spite of reading the datasheet.
    best regards.
  • Hi

    Thanks for your information:

    I am seeing that your 0x00 register which is the chip status register is showing 0x01. But if you need to turn your Tx and Rx ON.. you need to set the register 0x00 to 0x21. (For transmitter and receiver both to be on)

    Also state if IRQ register giving 0x80 means Tx complete...if you see the register 0x0C in the datasheet

    Check the function: trf7970a_send_cmd()

    Inside this function it calls function trf7970a_per_cmd_config() where it is decided that which protocol type command should we send.

     Also if you are using ISO1593 tags we need to send command in the format:

    the value of prefix[0] is 0x8f    ( These logs are from the driver trf7970a_send_cmd() )
    the value of prefix[1] is 0x91
    the value of prefix[2] is 0x3d
    the value of prefix[3] is 0x0
    the value of prefix[4] is 0x10
    the value of prefix[5] is 0x26.

    The value of RSSI is 0x40 is not an issue.I was also getting this during my development. Right now your tags have not been detected. After the tags are detected you will get 10 byte UID (unique id) of the tag in your FIFO.

    First you will get 0x40 in the irq status register(0x0C) to show that Rx is completed. Then this function will call trf7970a_drain_fifo()

    where you will get the UID from tags.

    Before debugging neard first we need to debug the driver.

    Let me know your queries

    Thanks