cancel
Showing results for 
Search instead for 
Did you mean: 

I2C EEPROM 24C08 read write uint16_t and uint32_t?

parth kothiya
Senior

how to read write i2c eeprom using HAL_I2C_Mem_Read and HAL_I2C_Mem_Write function.

how to convert uint16_t to uint8_t and uint32_t to uint8_t

1 ACCEPTED SOLUTION

Accepted Solutions
aston
Associate II

HAL_I2C_Mem_Read( &hi2c1,IIC_ReadAddr, 10, I2C_MEMADD_SIZE_8BIT, process_read_buf, 2, 1000 );//read uint16_t command

HAL_I2C_Mem_Read( &hi2c1,IIC_ReadAddr, 10, I2C_MEMADD_SIZE_8BIT, process_read_buf, 4, 1000 );//read uint32_t command

So simple

View solution in original post

4 REPLIES 4
KnarfB
Principal III

These functions take a pointer to the data, i.e.

if uint32_t x; is a variable, you supply

(uint8_t*)(&x) for the pData and

sizeof(uint32_t) for the Size parameter.

hth

KnarfB

Piranha
Chief II

The question is about basic C data types and pointers. It belongs to a school/university introductory course, not a manufacturer specific forum.

https://www.tutorialspoint.com/cprogramming/c_passing_pointers_to_functions.htm

https://www.tutorialspoint.com/cprogramming/c_type_casting.htm

aston
Associate II

HAL_I2C_Mem_Read( &hi2c1,IIC_ReadAddr, 10, I2C_MEMADD_SIZE_8BIT, process_read_buf, 2, 1000 );//read uint16_t command

HAL_I2C_Mem_Read( &hi2c1,IIC_ReadAddr, 10, I2C_MEMADD_SIZE_8BIT, process_read_buf, 4, 1000 );//read uint32_t command

So simple

Thanks​ works well gives exactly things I want 😊👍🏻