2017-02-28 11:34 PM
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
__/|\__
2017-03-01 02:13 AM
What re the SDA/SCL waveforms when looking by an oscilloscope or logic analyzer?
JW
2017-03-01 10:12 AM
2017-03-01 10:37 AM
Try replacing
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);
by
HAL_I2C_Mem_Write( &hi2c1, 0x00A0, 0x0000, 8, my_dat, 3, 3000);
HAL_Delay(10);
HAL_I2C_Mem_Write( &hi2c1, 0x00A0, 0x0000, 2, my_dat, 0, 3000);
HAL_I2C_Mem_Read( &hi2c1, 0x00A1, 0x0000, 2, my_get, 3, 3000);
It a bit overblown, let's see if you get more than a Start/Stop
2017-03-01 01:11 PM
KIC,
that's no start/stop. Although the marks are barely visible, the yellow line is clearly permanently at zero. It means, the I2C machine attempts to do a START but as one of SDA/SCL is permanently low, it can't do that and gives up. I bet there's some error in the registers; I don't Cube so I don't know how to detect that in that realm.
SIRI.PISIT
find out why is the signal corresponding to the yellow line at zero, first. Even without any attempt to do I2C, after pins initialization, both pins shall be at one. You init them as open-drain, AF mode, properly chosen AF; and you do have external pullups?
JW
2017-03-01 02:18 PM
Power off on your eeprom to get back to I2C idle mode each time you try debug the I2C.
2017-03-01 07:38 PM
<<>> This is latest coding <<>>
// I2C_HandleTypeDef *hi2c, DevAddress, Trials, Timeout
my_i2c_status = HAL_I2C_IsDeviceReady( &hi2c1, (uint16_t)0xA1, (uint16_t)10, 3000);//-------------------------------------------------------------------------------------------------------------------//
/** my_i2c_status = 0x01.. or HAL_ERROR what happen.. T_T **///-------------------------------------------------------------------------------------------------------------------//
my_dat = 1;my_get = 0xFF;
//I2C_HandleTypeDef *hi2c, DevAddress, MemAddress, MemAddSize, *pData, Size, Timeout HAL_I2C_Mem_Write( &hi2c1, (uint16_t)0x00A0, (uint16_t)0, (uint16_t)8, &my_dat, 1, 3000); HAL_I2C_Mem_Read( &hi2c1, (uint16_t)0x00A1, (uint16_t)0, (uint16_t)8, &my_get, 1, 3000);//------------------------------------------------------------------------------------------------------------------------------------------------//
my_get = 0xFF
what is mistake ?
Thank you very much.
2017-03-01 08:05 PM
my_dat = 1;
my_get = 0xFF; //I2C_HandleTypeDef *hi2c, DevAddress, MemAddress, MemAddSize, *pData, Size, Timeout HAL_I2C_Mem_Write( &hi2c1, (uint16_t)0x00A0, (uint16_t)0, (uint16_t)8, &my_dat, 1, 3000); HAL_I2C_Mem_Read( &hi2c1, (uint16_t)0x00A1, (uint16_t)0, (uint16_t)8, &my_get, 1, 3000);What is mistake..??
T T
2017-03-02 02:22 AM
The chip slave address A0 is NACK => either the slave address is wrong, or bad soldering, or SDA/SCL connection is wrong. If possible, probe the EEPROM package pins and make sure it has supply and ground ok.
2017-03-02 02:58 AM
I think my soldering is ok, i checked :)
and this is datasheet of EEPROM
but now, i don not understand
what is mistake ??
T_T!
and latest, this is code :
// I2C_HandleTypeDef *hi2c, DevAddress, Trials, Timeout
//my_i2c_status = HAL_I2C_IsDeviceReady( &hi2c1, (uint16_t)0xA1, (uint16_t)10, 3000); my_dat = 0x55; my_get = 0x00; //I2C_HandleTypeDef *hi2c, DevAddress, MemAddress, MemAddSize, *pData, Size, Timeout HAL_I2C_Mem_Write( &hi2c1, (uint16_t)0x00A0, (uint16_t)0, (uint16_t)1, &my_dat, 1, 3000); HAL_I2C_Mem_Read( &hi2c1, (uint16_t)0x00A1, (uint16_t)0, (uint16_t)1, &my_get, 2, 3000);and this is a capture from Saleae analyzer:
in last lie of coding.. i set addr = 0xA1
but it as 0xA0 on Scope. O_o!
i do not understand.
Thank you very much
_/\_