cancel
Showing results for 
Search instead for 
Did you mean: 

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

Shruthi
Associate II

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)

1 ACCEPTED SOLUTION

Accepted Solutions
Rene Lenerve
ST Employee

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.

View solution in original post

11 REPLIES 11
Rene Lenerve
ST Employee

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
Associate II

 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

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
Associate II

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.

Hi Shruthi,

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

Regards, Ulysses

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.

Hi Shruthi,

the recommendation is to look at SDA/SCL signals on ST25DV board: Use ideally an oscilloscope to look at the I2C traffic. Does it arrive at the board? And further on you can also see if ST25DV tries to acknowledge its address.

Regards, Ulysses

I did this and realized that there was no clock on SCL pin on ESP32 . I interfaced with STM-DK and works fine. Thanks for the support.

In continuation with this question, My I2C init is still failing because of i2c error at BSP_NFCTAG_GetExtended_Drv()->ResetMBEN_Dyn();

There is an write error here.

uint8_t* aTxBuffer[1] = {0};
 
	while(HAL_I2C_Mem_Write(&hi2c1, (uint16_t)(0xa6), (uint16_t)(0x2006), 2, (uint8_t *)aTxBuffer, 1, 1000)!= HAL_OK)
	{
		printf("Error in I2C IO Write\n");
	}

This the hardcoded data that I'm trying to communicate to reset MBDyn_Enable.

I tried with both 1Mhz(fast mode) and 100KHz . Both failed.

I also Read MB_mode and it was '0'. I tried to write '1' to this register which also failed and gave same i2c error

uint8_t* aTxBuffer[1] = {0x01};
	while(HAL_I2C_Mem_Write(&hi2c1, (uint16_t)(0xae), (uint16_t)(0x000d), 2, (uint8_t *)aTxBuffer, 1, 1000)!= HAL_OK)
	{
		printf("Error in I2C IO Write\n");
	}

Here are the clock images.

0693W00000Bax19QAB.jpg0693W00000Bax0uQAB.jpg