void FlashObj::ChipErase(void)
{
Busy = true;
FLASH[0x5555] = 0xaa;
FLASH[0x2AAA] = 0x55;
FLASH[0x5555] = 0x80;
FLASH[0x5555] = 0xaa;
FLASH[0x2AAA] = 0x55;
FLASH[0x5555] = 0x10;
Wait(FLASH[0x5555]);
Busy = false;
}
在函数ChipErase中,Flash变量地址0x85555是用FLASH[0x5555]表达的.
这样用数组寻址比较直观~~~
实现方法如下:
1.在CMD文件中
MEMORY
{
PAGE 0: /* Program Memory */
PAGE 1: /* Data Memory */
ERAM : origin = 0x100000, length = 0x04000
EFLASH : origin = 0x080000, length = 0x10000
}
SECTIONS
{
ERamRegsFile : > ERAM, PAGE = 1
EFlashRegsFile : > EFLASH, PAGE = 1
}
2.在C/C++文件中
#pragma DATA_SECTION("ERamRegsFile")
volatile unsigned int RAM[0x4000];
#pragma DATA_SECTION("EFlashRegsFile")
volatile unsigned int FLASH[0x10000];
3.在应用程序中
extern unsigned int RAM[];
extern unsigned int FLASH[];