stm8s105内部EEPROM读写的问题 10
向stm8s105内部EEPROM写入数据后,下次重新下载别的程序后原先写入的数据会被擦除吗?有什么办法保存数据吗?...
向stm8s105内部EEPROM写入数据后,下次重新下载别的程序后原先写入的数据会被擦除吗?有什么办法保存数据吗?
展开
2015-02-08
展开全部
void EEP_unlock()
{
FLASH->DUKR = 0xAE;
FLASH->DUKR = 0x56;
while(!(FLASH->IAPSR & 0x08));
}
void EEPROM(u16 adress,u32 Data)
{
FLASH->CR2 = 0;
FLASH->CR2 |= 0x40;
FLASH->NCR2 &= 0xBF;
*(unsigned char *)adress = (u8)(Data>>24);
*(unsigned char *)(adress+1) = (u8)(Data>>16);
*(unsigned char *)(adress+2) = (u8)(Data>>8);
*(unsigned char *)(adress+3) = (u8)Data;
while((FLASH->IAPSR & 0x04)==0);
}
把地址改掉就好了
{
FLASH->DUKR = 0xAE;
FLASH->DUKR = 0x56;
while(!(FLASH->IAPSR & 0x08));
}
void EEPROM(u16 adress,u32 Data)
{
FLASH->CR2 = 0;
FLASH->CR2 |= 0x40;
FLASH->NCR2 &= 0xBF;
*(unsigned char *)adress = (u8)(Data>>24);
*(unsigned char *)(adress+1) = (u8)(Data>>16);
*(unsigned char *)(adress+2) = (u8)(Data>>8);
*(unsigned char *)(adress+3) = (u8)Data;
while((FLASH->IAPSR & 0x04)==0);
}
把地址改掉就好了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询