2021-08-18 02:02 AM
During initialization of CC, as I understand we should have values 0xe1,0x40,0x40,0x00
But I am getting 0xe1,0x40,0x40,0x43. Im trying to manually write 0xe1,0x40,0x40,0x00 at address 0xa6, 0x00 which is failing.
I ignored that and tried to write a text NDEF tag to it which is also failing.
Please check the screenshot.
Step1 : Im writing CC at 0xa6,0x00 address- which failed.
Step2 : Writing length at 0xa6,0x04 address - success
Step3 : writing text NDEF tag at 0xa6,0x06 address - fail
Step4 : reading NDEF data- reading old text NDEF tag present on NFC.
Why is the write operation failing ? Are there any other registers to be set before writing?
Solved! Go to Solution.
2021-09-03 02:20 AM
sent the file over mail.
2021-09-03 02:30 AM
2021-09-03 05:49 AM
Hello Shruthi,
Thank you for the trace, it really helps to understand the issue.
Your I2C trace shows that the I2C writes are not correctly framed.
In the Session_I2C_Init trace, you can see that starting at time 3172501208.
Your write frame is this:
Start/A6/Ack/00/Ack/04/Ack/03/Ack/Start/A6/Ack/C1/Ack/Stop.
I guess you are trying to write value 03h at address 0004h, and then value C1h.
There is two things wrong in this sequence:
This is all explained in detail in datasheet chapter "6.4 I2C Write operations".
Correct sequence is:
Start/A6/Ack/00/Ack/04/Ack/03/Ack/C1/Ack/Stop.
or, if you want to do it in 2 times:
Start/A6/Ack/00/Ack/04/Ack/03/Ack/Stop Start/A6/Ack/00/Ack/05/Ack/C1/Ack/Stop.
The next write sequences all suffer from the same problem, and this is why no data is ever written to the tag's memory.
Best regards.
2021-09-21 02:31 AM
2021-09-22 11:58 PM
Hello,
"While addressing the device itself, there is no acknowledgement": do you mean after the first byte (the device slave address) there is not acknowledgement ?
This means that the device is not available for processing an I2C command. This can happen in 3 cases:
I guess you may be in the third case. I suppose you are writing the terminator TLV right after updating the NDEF message content ?
When updating the NDEF message, you are writing into the EEPROM memory. The I2C bus is then unavailable during the programming time of the EEROM: the device needs 5ms to program each 4 bytes of data. The write is starting at the stop bit of the I2C write command.
So, you should wait the end of EEPROM programming before being able to access the tag again.
This is explained in the datasheet, in chapter "6.4.2 I2C Sequential write".
Best regards.
2021-09-23 02:57 AM
Got it. Thanks a lot for the support.
2024-10-15 07:04 AM
I meet the same question.
here is the solution.
for esp-idf, the i2c addr means bit0~bit6,
but for nfc06a, the i2c addr means bit1~bit7,
when I scan the i2c devices, 0x2d 0x53 0x57 are active,
so, just set (addr >> 1), during write and read.
int32_t pltf_i2c_read_reg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
{
i2c_device_config_t i2c_dev_conf = {
.scl_speed_hz = 1000000,
.device_address = DevAddr >> 1,
};
i2c_master_dev_handle_t dev_handle;
if (i2c_master_bus_add_device(i2c_master_handle, &i2c_dev_conf, &dev_handle) != ESP_OK)
{
return ESP_FAIL;
}
uint8_t reg_buf[2] = {Reg >> 8, Reg & 0xFF};
esp_err_t ret = i2c_master_transmit_receive(dev_handle, reg_buf, 2, pData, Length, 50);
i2c_master_bus_rm_device(dev_handle);
return ret;
}
int32_t pltf_i2c_write_reg16(uint16_t DevAddr, uint16_t Reg, uint8_t *pData, uint16_t Length)
{
i2c_device_config_t i2c_dev_conf = {
.scl_speed_hz = 1000000,
.device_address = DevAddr >> 1,
};
i2c_master_dev_handle_t dev_handle;
if (i2c_master_bus_add_device(i2c_master_handle, &i2c_dev_conf, &dev_handle) != ESP_OK)
{
return ESP_FAIL;
}
uint8_t *p_data = malloc(Length + 2);
if (p_data == NULL)
{
i2c_master_bus_rm_device(dev_handle);
return ESP_FAIL;
}
p_data[0] = Reg >> 8;
p_data[1] = Reg & 0xFF;
memcpy(&p_data[2], pData, Length);
esp_err_t ret = i2c_master_transmit(dev_handle, p_data, Length + 2, 50);
i2c_master_bus_rm_device(dev_handle);
free(p_data);
return ret;
}
int32_t pltf_i2c_is_ready(uint16_t DevAddr, uint32_t Trials)
{
esp_err_t ret = i2c_master_probe(i2c_master_handle, (DevAddr >> 1), 50);
return ret;
}