现在用NUC029SGE,定义了两个页作为内部存储用。一个起始地址为0x3FC00,一个起始地址为0x3FE00,在程序应用时,对起始地址0x3FE00进行读写操作都是正常的,但是对起始地址为0x3FC00进行读写操作却是不行的。同样的代码,只是地址不一样。
int FlashRead(long subadd,unsigned short *dat,unsigned int len)
{
unsigned int i;
SetDataFlashBase(SHARP_SAVE_ADDR);
SYS_UnlockReg();
FMC_Open();
for(i = 0;i < len;i ++)
{
*dat++ = (short)FMC_Read(subadd);
subadd += 4;
}
FMC_Close();
SYS_LockReg();
return OPERATION_SUCCESS;
}
int FlashWrite(long subadd,unsigned short *dat,unsigned int len)
{
unsigned int i;
SetDataFlashBase(subadd);
if(FlashErase(subadd) == OPERATION_SUCCESS)
{
SYS_UnlockReg();
FMC_Open();
for(i = 0; i < len; i ++)
{
FMC_Write(subadd,*dat++);
subadd += 4;
}
FMC_Close();
SYS_LockReg();
return OPERATION_SUCCESS;
}
return OPERATION_FAILED;
}
应用中 FlashWrite(0x3FC00,&aa[0],15);FlashRead(0x3FC00,&aa[0],15); 不管我把aa赋值为多少,写入读取后,aa都是0xFFFF
FlashWrite(0x3FE00,&aa[0],15);FlashRead(0x3FE00,&aa[0],15);只要我修改了aa的值后,写入读取均为我给aa所附的值。
|