2015-12-02 06:03 AM
Hello everyone,
I am new to this forum and to ST microcontrollers and need some help.. Trying to inialize and pick the right functions for Read and Write from the cube(HAL) libraries, to connect with an external Eeprom. I have to make a function that will have as inputs the Memory address of the eeprom and the data to put in, if we assume that we will be always writing the same size of data. will it be like this?/* I2C1 init function */
void MX_I2C1_Init(void)
{
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 100000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
HAL_I2C_Init(&hi2c1);
}
/////////////////////
///////////////////// void EEPromWrite(... Memory_Adress, ... aTxBuffer )
{
while (HAL_I2C_Mem_Write(&I2cHandle , (uint16_t)EEPROM_ADDRESS, Memory_Address, I2C_MEMADD_SIZE_16BIT, (uint8_t*)(aTxBuffer + Memory_Address), TXBUFFERSIZE, 10000)!= HAL_OK)
{
if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)
{
Error_Handler();
}
}
}
I dont understand why sum the aTxBuffer with Memory_Address ?
If you can point out some similar examples would be very helpful. Thank you
2015-12-02 08:27 AM
Hi robber,
If you look for similar example using EEPROM, I suggest you this one: STM32Cube_FW_F4_V1.9.0\Projects\STM32469I_EVAL\Examples\I2C\I2C_EEPROM.-Mayla-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.