在例程中,使用
void DataFlashTest(void)
{
/* Read Data Flash base address 0x0001F000*/
uint16_t u16Temp;
u32DataFlashBase = DrvFMC_ReadDataFlashBaseAddr();
printf(" Data Flash Base Address .................... [0x%08x]\n", u32DataFlashBase);
printf(" Erase Data Flash ........................... ");
EraseDataFlash();
printf(" Program Data Flash ......................... \n\n");
i=257;
SetTempOffset(i);
u16Temp=GetTempOffset();
printf(" into addr [0x%08x],Read out Data is .. [0x%08x]\n", FlashTempOffsetAddr,u16Temp);
i=258;
SetTempOffset(i);
u16Temp=GetTempOffset();
printf(" into addr [0x%08x],Read out Data is .. [0x%08x]\n", FlashTempOffsetAddr,u16Temp);
i=0x1101;
SetTempOffset(i);
u16Temp=GetTempOffset();
printf(" into addr [0x%08x],Read out Data is .. [0x%08x]\n", FlashTempOffsetAddr,u16Temp);
i=0xFF;
SetTempOffset(i);
u16Temp=GetTempOffset();
printf(" into addr [0x%08x],Read out Data is .. [0x%08x]\n", FlashTempOffsetAddr,u16Temp);
}
其中
void SetTempOffset(uint16_t TempOffset)
{
uint32_t u32TempOffset;
u32TempOffset=(uint32_t)TempOffset;
UNLOCKREG();
DrvFMC_EnableISP();
DrvFMC_Write(FlashTempOffsetAddr,u32TempOffset);
printf("Write Data [0x%08x]",u32TempOffset);
LOCKREG();
DrvFMC_DisableISP();
}
uint16_t GetTempOffset(void)
{
uint32_t u32TempOffset;
UNLOCKREG();
DrvFMC_EnableISP();
DrvFMC_Read(FlashTempOffsetAddr, &u32TempOffset);
LOCKREG();
DrvFMC_DisableISP();
return (uint16_t)u32TempOffset;
}
发现一个问题,就是在格式化后同一个FLASH的地址的数据好像只能被改写一次,好像是写成0的再不可能被写成1了,第二次格式化后有好了,请教下大家遇到这个问题没 |