关于flash擦除的问题?
时间:10-02
整理:3721RD
点击:
下面是我用的flash擦除程序,用软件仿真的时候可以擦除掉给定地址的扇区,但在线调试的时候发现程序一运行到*pwrite = 1; 语句时就会自动复位,没有实现擦除,不知道是怎么回事,求大神们帮忙啊!
void ClrFlash(uint addr)
{
char xdata * data pwrite;
EA = 0; //Disable interrupts
//change clock speed to slow, then restore later
VDM0CN = 0x80; // Enable VDD monitor
RSTSRC = 0x02; // enable VDD monitor as a reset source
pwrite = (char xdata *)addr;
FLKEY = 0xA5; // Key Sequence 1
FLKEY = 0xF1; // Key Sequence 2
PSCTL = 0x03; // PSWE = 1; PSEE = 1
VDM0CN = 0x80; // Enable VDD monitor
RSTSRC = 0x02; // Enable VDD monitor as a reset source
*pwrite = 1; // Initiate page erase
PSCTL &= ~0x03; // PSWE = 0; PSEE = 0
EA = 1; //Restore interrupts
}
void ClrFlash(uint addr)
{
char xdata * data pwrite;
EA = 0; //Disable interrupts
//change clock speed to slow, then restore later
VDM0CN = 0x80; // Enable VDD monitor
RSTSRC = 0x02; // enable VDD monitor as a reset source
pwrite = (char xdata *)addr;
FLKEY = 0xA5; // Key Sequence 1
FLKEY = 0xF1; // Key Sequence 2
PSCTL = 0x03; // PSWE = 1; PSEE = 1
VDM0CN = 0x80; // Enable VDD monitor
RSTSRC = 0x02; // Enable VDD monitor as a reset source
*pwrite = 1; // Initiate page erase
PSCTL &= ~0x03; // PSWE = 0; PSEE = 0
EA = 1; //Restore interrupts
}
访问flash 指针应该是在code区吧
网上的例程都是这样写的,说是写Flash要用movx指令,必须把指针指向xdata类型,而且软件仿真的时候这样是正确的,确实擦除了...但是在线仿真的时候就不行...
资料给力,谢谢分享!
资料完整,类容丰富,作者爆满@@@!
路过。挣点积分。
tongwen!