stm3240g-eval eeprom(M24C64) issue.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2020-09-07 01:34 AM
Hello
I test external eeprom (M24C64) on the STM3240G-EVAL.
But it doesn't work well.
HAL_I2C_Mem_WriteBytes() and HAL_I2C_Mem_ReadBytes() return the HAL_OK.
But when I check the data[] buffer, the value is all "255".
This mean that memory is empty?
The Device address is 0xA0.
Write_Control pin is high.(M24C64)
Help me.!!
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_I2C1_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
uint8_t data[10] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99};
if (HAL_I2C_Mem_Write(&hi2c1, 0xA0, 0x00, I2C_MEMADD_SIZE_8BIT, &data[0], 10, 10) == HAL_OK)
for (int i = 0; i < 10; i++) data[i] = 0x00;
if(HAL_I2C_Mem_Read(&hi2c1, 0xA0, 0x00, I2C_MEMADD_SIZE_8BIT, &data[0], 10, 10) == HAL_OK)
for (int i = 0; i < 10; i++) data[i] = 0x00;
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
This is my code
Labels:
- Labels:
-
I2C
-
STM32F4 Series
0 REPLIES 0