在线时间0 小时
UID197284
ST金币0
蝴蝶豆0
注册时间2007-12-19
新手上路
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2011-8-31 13:12:42
|
显示全部楼层
a0a.1 0b0c
RE:STM8L读写EEPROM偶尔会死机
根据官方例程改写的程序:
void EE_WRITE(void)
{
/* Define flash programming Time*/
FLASH_SetProgrammingTime(FLASH_ProgramTime_Standard);
FLASH_Unlock(FLASH_MemType_Program);
/* Wait until Flash Program area unlocked flag is set*/
while (FLASH_GetFlagStatus(FLASH_FLAG_PUL) == RESET)
{}
/* Unlock flash data eeprom memory */
FLASH_Unlock(FLASH_MemType_Data);
/* Wait until Data EEPROM area unlocked flag is set*/
while (FLASH_GetFlagStatus(FLASH_FLAG_DUL) == RESET)
{}
/* Erase block 0 and verify it */
/* This function is executed from RAM */
FLASH_EraseBlock(BLOCK_OPERATION, FLASH_MemType_Data);
/* Wait until End of high voltage flag is set*/
while (FLASH_GetFlagStatus(FLASH_FLAG_HVOFF) == RESET)
{}
/* This function is executed from RAM */
FLASH_ProgramBlock(BLOCK_OPERATION, FLASH_MemType_Data, FLASH_ProgramMode_Standard, ramBuf);
/* Wait until End of high voltage flag is set*/
while (FLASH_GetFlagStatus(FLASH_FLAG_HVOFF) == RESET)
{}
}
ramBuf是自己定义的数组:uint8_t ramBuf[FLASH_BLOCK_SIZE];
程序进:FLASH_EraseBlock后死在里面 |
|