Skip to main content
Shruthi
Associate III
May 13, 2021
Solved

NFCTagInitialise is failing since I2C read operation from system register on NFC is failing.

  • May 13, 2021
  • 5 replies
  • 2812 views

Hi,

Im trying to interface ST25DV04K-8pin with ESP32Wroom. I have initialized I2C communication on ESP as Master. 

Source files for ST25DV NFC - https://github.com/stm32duino/ST25DV/tree/master/src

NFCTagInitialise is failing as it is not reading the system Information at 0x17, 0x18-0x1f.

ESP - I2C driver returns error (-1). ESP is unable to write the target address to NFC chip (invalid address). Hence Read buffer is not loaded with the data from slave (NFC module)

This topic has been closed for replies.
Best answer by Rene Lenerve

Hi @Shruthi​,

To write configuration registers you need to open an i²C security session. To do that you have to present a password, by default the 64-bit password is 0 (refer to I2C_PWD access in the datasheet).

Did you open a security session before trying to write configuration registers?

Best regards.

5 replies

Rene Lenerve
ST Employee
May 18, 2021

Hi @Shruthi​ ,

Does the ST25DV is responding by an ACK to the Device address command on the I²C bus? (answer to this function ST25DV_IO_IsDeviceReady)

What can be checked is that you have a correct power supply for the ST25DV while trying to access the chip. If you are using the field to power up the ST25DV be careful to place the field on the antenna.

You can also check that you have correct pull-up resistors on the I²C bus (this depends on speed selected for the I²C bus).

Just for information the LPD pin is not available on the 8-pin package (this feature is only available on 12-pin package), but you can keep the LPD management in case you will need to use it.

Second point the 8-pin package is an open drain version for GPO, be careful to have a pull-up resistor on the GPO pin for a proper operation (not link to your current problem of course).

I hope this will help you.

Best Regards.

Shruthi
ShruthiAuthor
Associate III
May 21, 2021

 Thanks for the response.

ST25DV_IO_IsDeviceReady - This is failing with an i2c driver return value -1. I see that It is addressing 0xA6 where i2c is failing. Supply voltage is from the ESP32 development board 3.3V. I have added pull-up resistors of 10k to SDA and SCL lines for speed of 400000Hz.

Rene Lenerve
ST Employee
May 24, 2021

Hi @Shruthi​,

If you try to access system area (registers from ST25DV), the I²C address is 0xAE not 0xA6 for a write (and 0xAF for a read). But it should answer to the device address anyway if not busy.

For the pull-up resistor, on a 400 kHz bus speed, the value of the resistors should be lower (maybe more around 1.5 kOhm), but it depends on your circuit. You can easily found formulas on the web on I²C Bus Pull-Up Resistor Calculation.

This could be an explanation for the error return on i²C bus.

Best Regards.

Shruthi
ShruthiAuthor
Associate III
May 25, 2021

Hi,

I tried with 0xAF, 0xA7 device addresses for read and 0xAE, 0xA6, for write.

Below is the i2c command I'm sending where DevAddr = 0xAE and TarAddr is 0x17 (IC_ref info)

i2c_cmd_handle_t cmd = i2c_cmd_link_create();
  
 i2c_master_start(cmd); 
 i2c_master_write_byte(cmd, (DevAddr << 1) | WRITE_BIT, ACK_CHECK_EN); //slave address
 i2c_master_write_byte(cmd, (TarAddr >> 8), ACK_CHECK_EN ); //register address MSB 
 i2c_master_write_byte(cmd, (TarAddr & 0xFF), ACK_CHECK_EN ); //register address LSB
  
 i2c_master_start(cmd); //start with slave address 
 i2c_master_write_byte(cmd, ((DevAddr+0x01)<<1) | READ_BIT, ACK_CHECK_EN);  
 if (Size > 1) {
 i2c_master_read(cmd, pData, Size - 1, ACK_VAL);
 } 
		i2c_master_read_byte(cmd, pData + Size - 1, NACK_VAL); //read from the register 1 byte 
		i2c_master_stop(cmd);
 
		int ret = i2c_master_cmd_begin(i2c_num, cmd, 1000);
  
 i2c_cmd_link_delete(cmd);

I saw the formulas to calculate - R(min), I calculate to get,

(Vcc-VoL) / IoL = (3.3 - 0.4)/2.1m = 1.3kOhm

0693W00000APlyXQAT.jpg 

I also tried with different pull up resistor values like, 1kOhm, 1.5kOhm, 2kOhm pull up resistors, but same i2c error.

Ulysses HERNIOSUS
Technical Moderator
May 26, 2021

Hi Shruthi,

I think it would help if you could share some scope shots from the failing I2C communication?

Regards, Ulysses

Shruthi
ShruthiAuthor
Associate III
May 26, 2021

ST25DV source code ref : https://github.com/stm32duino/ST25DV/tree/master/src

My Program using ESP-IDF

#include "ST25DV_call.h" //Same as ST25DVSensor.cpp in the github reference
 
void app_main(void)
{
	ESP_ERROR_CHECK(st25dv_NFC_init());
	uint8_t *ret_uri=(uint8_t *)malloc(DATA_LENGTH); ;
	readURI(ret_uri);
}
 
---------ST25DV_call.c file attached------------------------------

0693W00000APqM4QAL.jpgDevice and target Address values printed. After reading we can see the I2C return value is -1

0693W00000APqUIQA1.jpgpin21 on ESP - SDA

pin22 on ESP - SCL

3.3V and gnd

pin 35 on ESP - GPO/RF

1kOhm in series to result 2kOhm pull up resistance.

Rene Lenerve
Rene LenerveBest answer
ST Employee
June 15, 2021

Hi @Shruthi​,

To write configuration registers you need to open an i²C security session. To do that you have to present a password, by default the 64-bit password is 0 (refer to I2C_PWD access in the datasheet).

Did you open a security session before trying to write configuration registers?

Best regards.