下面是我用的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
}
此帖出自
小平头技术问答
主函数里把看门狗已经禁止了还会这样子么....谢谢!
一周热门 更多>