这里写代码片
void EEPROOM_Configuration(void)
{
FLASH_DeInit();
FLASH_SetProgrammingTime(FLASH_PROGRAMTIME_STANDARD);
FLASH_Unlock(FLASH_MEMTYPE_DATA);
}
写一位数据
FLASH_ProgramByte(0x4000,0xaa);
读一位数据
read_data=FLASH_ReadByte(0x4000);
这里写代码片
#define EEPROM_ADDR 0x4020
#define BUF_SIZE 10
uint8_t WriteBuf[BUF_SIZE] = {'5', '6', '7', '8', '9','4', '3', '2', '1', '0' };
uint8_t ReadBuf[BUF_SIZE];
void EEPROM_Initializes(void)
{
FLASH->CR1 &= (uint8_t)(~0x01);
FLASH->CR1 |= (uint8_t)0x00;
}
void EEPROM_WriteNByte(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t nByte)
{
do
{
FLASH->DUKR = 0xae;
FLASH->DUKR = 0x56;
} while((FLASH->IAPSR & 0x08) == 0);
asm("nop");
while(FLASH_GetFlagStatus(FLASH_FLAG_DUL) == RESET);
asm("nop");
while(nByte--)
{
FLASH_ProgramByte(WriteAddr, *pBuffer);
WriteAddr++;
pBuffer++;
FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);
asm("nop");
}
FLASH->IAPSR &= 0xF7;
}
void EEPROM_ReadNByte(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t nByte)
{
while(nByte--)
{
*pBuffer = FLASH_ReadByte(ReadAddr);
ReadAddr++;
pBuffer++;
}
}