cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot read config register value of M24LR16E via I2C

Hae Ryon Jung
Associate III
Posted on June 07, 2018 at 09:34

Hi All,

I'm trying to communicate with M24LR16E(NFC tag IC) via I2C (STM32F103R is Master)

I could find configuration register(address 2320) has initial value 0xF4.

so I tried to read the configuration register, but I got 0xFF.

would you please take a look at what is wrong with my code ?

=======================

uint16_t NFC_sys_addr = 0xAE, nfc_conf_addr=2320;

uint8_t nfc_config=0;

HAL_I2C_Master_Transmit(&hi2c1, 0xAE, (uint8_t *)&nfc_conf_addr, 2, 100); // set config register address

HAL_I2C_Master_Receive(&hi2c1, 0xAE, (uint8_t *)&nfc_config, 1, 100); // read byte

printf('NFC config 0x%x\r\n', (unsigned int)nfc_config);

========================

Thanks in advance

Best Regards,

Hae Ryong

#i2c-isues #m24lr16e
1 REPLY 1
Hae Ryon Jung
Associate III
Posted on June 07, 2018 at 11:32

I verified following code working fine

=================

uint16_t NFC_sys_addr = 0xAE, nfc_conf_addr=2320;

HAL_StatusTypeDef i2c_status=HAL_OK;

uint8_t i2c_wBuf[3];

uint8_t i2c_value=0;

i2c_wBuf[0] = (uint8_t)((nfc_conf_addr&0xFF00) >> 8);

i2c_wBuf[1] = (uint8_t)(nfc_conf_addr&0x00FF);

i2c_status = HAL_I2C_Master_Transmit(&hi2c1, NFC_sys_addr, (uint8_t *)i2c_wBuf, 2, 100);

HAL_Delay(10);

i2c_status = HAL_I2C_Master_Receive(&hi2c1, NFC_sys_addr, (uint8_t *)&i2c_value, 1, 100);

printf('NFC value 0x%x at 0x%x, status=%d\r\n', (unsigned int)i2c_value, nfc_addr, i2c_status);

==================

I could see i2c_value is 0xF4

I guess

nfc_conf_addr value should be converted to i2c_wBuf[] for HAL_I2C_Master_Transmit() and HAL_I2C_Master_Receive()

Thanks anyway.