NT3H2211 NTAG I2C Plus won't read/write registers over I2C

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NT3H2211 NTAG I2C Plus won't read/write registers over I2C

579 Views
ZicMortal
Contributor I

Greetings everyone,

As the title says, I have issues with NT3H2211W0FTTJ NTAG. 

I am currently using STM32L010 MCU, and I am trying to port the official library from NXP to work on my MCU.

My original reference library is from here (SW3647 > workspace_ntag_i2c_plus): https://www.google.com/search?q=om5569%2Fnt322erm&oq=om&aqs=chrome.1.69i57j69i59l2j0i131i433j46i131i...

 

 

 

In my code, I have tested I2C Communication, and I get HAL_OK responses for the following code, meaning that I2C is OK communication-wise:

---------------------------------------------------------------------------------

#define NTAG_I2C_READ 0xAB
#define NTAG_I2C_WRITE 0xAA

result = HAL_I2C_IsDeviceReady(&hi2c1, NTAG_I2C_READ, 2, 5);
if (result == HAL_OK) PRINTF("READ ADDRESS OK!\r\n");
result = HAL_I2C_IsDeviceReady(&hi2c1, NTAG_I2C_WRITE, 2, 5);
if (result == HAL_OK) PRINTF("WRITE ADDRESS OK!\r\n");*/

---------------------------------------------------------------------------------

 

 

 

The problem I get is, from the following code I get READ2 FAILED (these functions are from the reference library):

---------------------------------------------------------------------------------

uint8_t NTAG_ReadRegister(NTAG_HANDLE_T ntag, uint8_t reg, uint8_t *val) {
ntag->tx_buffer[TX_START + 0] = NTAG_MEM_BLOCK_SESSION_REGS;
ntag->tx_buffer[TX_START + 1] = reg;

/* send block number */
if ( HAL_OK != HAL_I2C_SendBytes(ntag->i2cbus, ntag->address, ntag->tx_buffer, 2))
{
ntag->status = NTAG_ERROR_TX_FAILED;

PRINTF("READ1 FAILED\n");
return 1;
}

/* receive bytes */
if ( HAL_OK != HAL_I2C_RecvBytes(ntag->i2cbus, ntag->address, ntag->rx_buffer, 1))
{
ntag->status = NTAG_ERROR_RX_FAILED;

PRINTF("READ2 FAILED\n"); // THIS LINE HERE HAPPENS
return 1;
}

*val = ntag->rx_buffer[RX_START + 0];
return 0;
}

---------------------------------------------------------------------------------

 

 

 

The problem lies in the HAL_I2C_RecvBytes function

I have tried to port the following functions to STM32 (these are not from the reference library):

---------------------------------------------------------------------------------

HAL_StatusTypeDef HAL_I2C_RecvBytes(uint8_t i2cbus, uint8_t regAddress, uint8_t *byteData, uint8_t len)
{

return HAL_I2C_Master_Receive(&hi2c1, NTAG_I2C_READ, byteData, len, 100);

}

 

 

HAL_StatusTypeDef HAL_I2C_SendBytes(uint8_t i2cbus, uint8_t regAddress,uint8_t *dataToWrite, uint8_t len)
{
return HAL_I2C_Master_Transmit(&hi2c1, NTAG_I2C_WRITE, dataToWrite, len, 100);

}

---------------------------------------------------------------------------------

 

 

Sorry for the long post, I was hoping if someone has good advice on how to make it work on STM32.
Any help is really appreciated

Tags (1)
0 Kudos
1 Reply

568 Views
fangfang
NXP TechSupport
NXP TechSupport

Hello,

One may refer to  the document (it is NXP MCU)as the link. 

URL:https://community.nxp.com/t5/NXP-Designs-Knowledge-Base/BLE-pairing-with-the-NTAG-I2C-plus-kit-for-A....

Have a nice day.

 

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-----------------------------------------------------------------------------

0 Kudos