cancel
Showing results for 
Search instead for 
Did you mean: 

16-bit addresses register in i2c stm32

ssham.11
Associate

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

3 REPLIES 3
Foued_KH
ST Employee

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
Associate

I try it but the result is the same

S.Ma
Principal

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.