fjpmbb 发表于 2015-1-23 11:29
我这边 不能在线仿真,只能靠打印数据,所以读出的数据,我是调用flashread的方法来读取的,显示的数据不是 ...
我代码这么写的:
#define MY_FLASH_LOCATION 0x0001f000//0x00005ff0
volatile bool DataWritten标志寄存器 = FALSE;
char Data[] = "Hello world";
char Buffer[] = " ";
LDD_TError Error;
LDD_FLASH_TOperationStatus OpStatus;
LDD_TDeviceData *MyFLASH_Ptr;
main()中:
MyFLASH_Ptr = FLASH1_Init(NULL);
Error = FLASH1_Write(MyFLASH_Ptr, Data, MY_FLASH_LOCATION, sizeof(Data));
do {
FLASH1_Main(MyFLASH_Ptr);
OpStatus = FLASH1_GetOperationStatus(MyFLASH_Ptr);
} while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));
Error = FLASH1_Read(MyFLASH_Ptr, MY_FLASH_LOCATION, Buffer, sizeof(Buffer)); /* Start reading from the flash memory */
do {
FLASH1_Main(MyFLASH_Ptr);
OpStatus = FLASH1_GetOperationStatus(MyFLASH_Ptr);
} while (!((OpStatus == LDD_FLASH_IDLE) | (OpStatus == LDD_FLASH_FAILED)));
if (OpStatus == LDD_FLASH_FAILED) { /* Check if the operation has successfully ended */
/* Error state solution */
}
测试结果:“
可以看到,经过flash写命令,Hello world已经被写到0x0001f000地址。
读取的时候,把0x0001f000地址的值读到buff,可以看到,结果是正确的。
|