控制芯片用的STM32F103,不知道这个EEPROM跨页写是怎么操作的?试了很久还是只能正常读写前16个,查了很多资料,感觉要跨页写可以重新指定新页地址,这样就不存在跨页,如下程序所示:
if(HAL_I2C_Mem_Write(&hi2c2, ADDR_24LC02_Write, 0, I2C_MEMADD_SIZE_8BIT, WriteBuffer, 16, 0x10) == HAL_OK)
{
while(HAL_I2C_IsDeviceReady(&hi2c2, ADDR_24LC02_Write, 20, 0x10))
HAL_Delay(5);
if(HAL_I2C_Mem_Write(&hi2c2, ADDR_24LC02_Write, 0x10, I2C_MEMADD_SIZE_8BIT, WriteBuffer+16, 16, 0x10) == HAL_OK)
{
while(HAL_I2C_IsDeviceReady(&hi2c2, ADDR_24LC02_Write, 20, 0x10))
HAL_Delay(5);
if(HAL_I2C_Mem_Write(&hi2c2, ADDR_24LC02_Write, 0x20, I2C_MEMADD_SIZE_8BIT, WriteBuffer+32, 16, 0x10) == HAL_OK)
{
while(HAL_I2C_IsDeviceReady(&hi2c2, ADDR_24LC02_Write, 20, 0x10))
HAL_Delay(5);
}
}
}
但是,结果就是不成功。望有经验的盆友指点一二。 |