在线时间8 小时
UID422107
ST金币0
蝴蝶豆0
注册时间2013-3-20
初级会员
- 最后登录
- 2018-4-6
|
发表于 2013-12-31 20:19:55
|
显示全部楼层
a0a.1 0b0c
RE:stm8s eeprom如何在代码中预置数据?
#include "stm8s_conf.h"
void __eeprom_write_8(unsigned short addr_eep,unsigned char data)
{
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_Unlock(FLASH_MEMTYPE_DATA);
FLASH_ProgramByte(addr_eep, data);
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_Lock(FLASH_MEMTYPE_DATA);
}
void __eeprom_write_16(unsigned short addr_eep,unsigned short data)
{
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_Unlock(FLASH_MEMTYPE_DATA);
FLASH_ProgramByte(addr_eep, data/256);
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_ProgramByte(addr_eep+1, data%256);
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_Lock(FLASH_MEMTYPE_DATA);
}
void __eeprom_write_32(unsigned short addr_eep,unsigned long data)
{
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_Unlock(FLASH_MEMTYPE_DATA);
FLASH_ProgramByte(addr_eep, (unsigned char)(data>>24));
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_ProgramByte(addr_eep+1, (unsigned char)(data>>16));
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_ProgramByte(addr_eep+2, (unsigned char)(data>>8));
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_ProgramByte(addr_eep+3, (unsigned char)(data>>0));
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_Lock(FLASH_MEMTYPE_DATA);
}
void __eeprom_write_many(unsigned short addr_eep,unsigned short size,unsigned short dummy,unsigned short addr_ram)
{
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
FLASH_Unlock(FLASH_MEMTYPE_DATA);
for(unsigned short i=0;i |
|