I2C EEPROM 24C08 read write uint16_t and uint32_t?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-30 6:30 AM
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
Solved! Go to Solution.
- Labels:
-
EEPROM devices
-
I2C
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-30 5:47 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-30 8:41 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-30 11:13 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-30 5:47 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2021-12-30 10:29 PM
Thanks works well gives exactly things I want :smiling_face_with_smiling_eyes:👍🏻
