一、描述
- 读:从FLASH将数据赋值给buff;
- 写:从buff将数据赋值给FLASH;
DataFlash特点:
擦/ERASE | 写/READ | 读/WRITE |
0.25KB(的倍数)/4KB(的倍数) | 1Byte/多个Byte/256Byte(的倍数,best) | 1Byte/多Byte |
CodeFlash特点:
擦/ERASE | 写/READ | 读/WRITE |
4KB(的倍数) | 4Byte | 4Byte/256Byte(的倍数,best) |
二、实例
实现功能:按下RESET后MAC地址自加1。
实现方式:①先将FLASH的内容赋值给buf;②然后让buf[0]的内容自加;③擦除FLASH的内容;④将buf[0]的内容写给FLASH。
void FLASH_Init(){
uint8 status = R8_RESET_STATUS;
if(((status & 0x07) == 0x01 ))
{
MACBuf[0] = 6; MACBuf[1] = 3; MACBuf[2] = 4; MACBuf[3] = 5;
PRINT("Inter...\r\n");
EEPROM_ERASE(0, EEPROM_PAGE_SIZE);
EEPROM_WRITE(0, MACBuf, 4);
}
uint8 ret = EEPROM_READ(0, MACBuf, 4);
PRINT("MACBuf[0] = %02x \r\n", MACBuf[0]);
MACBuf[0]++;
EEPROM_ERASE(0, EEPROM_PAGE_SIZE);
EEPROM_WRITE(0, MACBuf, 4);
for(uint8 i = 0; i < 4; i++)
{
PRINT("%02x ", MACBuf[i]);
}PRINT("\n");
}
cfg.MacAddr[i] = MACBuf[0];
标签:FLASH,MACBuf,WRITE,CH58xFLASH,ERASE,PRINT,操作,EEPROM From: https://www.cnblogs.com/gscw/p/17328009.html