cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103C8, I2C1 with EEPROM_AT24C16C, it does not work T_T!

mrtaotao789
Associate II
Posted on March 01, 2017 at 08:34

Initial Gencode : CubeMX : V4.19

IDE : KEIL       : V5.23.0.0 

HW : EEPROM : AT24C16C

minimum board STM32F103C8T6

HSE 72MHz

i pullup SDA, SCL with R 4k7 (PB7 & PB6)

Mode speed 100kHz

// this is my code.. //

my_i2c_status[0] = HAL_I2C_IsDeviceReady( &hi2c1,(uint16_t)0xA1,(uint16_t)10,3000);

my_dat[0] = 10;

my_dat[1] = 11;

my_dat[2] = 12;

my_get[0] = 0;

my_get[1] = 0;

my_get[2] = 0;

HAL_I2C_Mem_Write( &hi2c1,(uint16_t)0x00A0, (uint16_t)0, (uint16_t)8, my_dat, 3, 3000);

HAL_I2C_Mem_Read( &hi2c1,(uint16_t)0x00A1, (uint16_t)0, (uint16_t)8, my_get, 3, 3000);

my_get[0] =0 ,

my_get[1] =0 ,

my_get[2] =0 ,

It not change

T_T!

what is mistake in my code.

thank you very much

__/|\__

11 REPLIES 11
mrtaotao789
Associate II
Posted on March 04, 2017 at 06:55

Now, i can solve i2c,

Lib from HAL.. 

HAL_I2C_Mem_Read() :

Algorythm of HAL_Lib is not mathing with EEPROM, so it can not use

i coding easy functions for solve this problem and oscillope by Saleae Logic Analyzer,

i follow timing diagram of RM0008 of STM and data sheet of EEPROM

Now it work..

but HAL_I2C_Mem_Write() : it is correct, it can use

thank you every body 🙂

___/\___0690X00000606IMQAY.png0690X00000606OiQAI.png
Posted on March 05, 2017 at 03:47

could u please share how u used to work with the eeprom? i have not ur level of knowledge and have been struggling for like 1 week now trying to read and write from an AT24C02 , im using too an 

STM32F103C8T6,

i have tested this and many other kind of codes but nothing :S 

xBuffer[0] = 'M';

HAL_I2C_Mem_Write(&hi2c1, 0x57, 0x0007, 2, xBuffer, 1, 5);

HAL_Delay(10);

xBuffer[0] = 0x00;

HAL_I2C_Mem_Write(&hi2c1, 0x57, 0x0007, 2, xBuffer, 0, 5);

HAL_I2C_Mem_Read(&hi2c1, 0x57, 0x0007, 2, xBuffer, 1, 5);*/

HAL_Delay(2000);