Skip to main content
ssham.11
Associate
January 23, 2023
Question

16-bit addresses register in i2c stm32

  • January 23, 2023
  • 3 replies
  • 2978 views

hi

i want to write in AT24C512 with stm32f103c8 i send my code.

HAL_I2C_Mem_Write(&hi2c1, 0XA0, 0X11FA,I2C_MEMADD_SIZE_16BIT ,   &write_data, 1, 100);

For example, I want to put the value of write_data on 0x11FA, and I specify the memory address as 16 bits, but it is always sent as 8 bits, and AT24C512 seems to receive only the first byte of 0x11FA It means AT24C512 receive just 0x11 and its not difference if i set mt address register to 0x1167 0x11FF 0x11A0 all these address is same for AT24C512.

what should I do?

Because I used the module, I am sure the hardware have no problem

This topic has been closed for replies.

3 replies

Foued_KH
ST Employee
January 23, 2023

Hello @ssham.1​ 

 A way to write data from a 16 bit address is

HAL_I2C_Mem_Write(&hi2c1, 0XA0, 0x11FA, 2 ,  &write_data, 1, 100);

regAddr is 16 bit address and "2" is the size in bytes of regAddr= 0x11FA.

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ssham.11
ssham.11Author
Associate
January 23, 2023

I try it but the result is the same

S.Ma
Principal
January 23, 2023

If you are ok with I2C Bit-bang and EEPROM support with a single API (demonstrated with 24256), have a look at this to possibly give you clues.