This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
现在产品使用的是MSP430F4152,因为刚开始没有考虑那么全面 ,产品已经量产了安装了,数据存储用的是以下的代码:
void WaitForEnable() { while((FCTL3 & BUSY) == BUSY); //Busy } void WriteFlash(unsigned int Addr,unsigned char *Data,unsigned char DataLend) { WDTCTL = WDTPW+WDTHOLD; char i; char *FlashPtr = (char *)Addr; // Segment pointer FCTL1 = FWKEY + WRT; // Set WRT bit for write operation FCTL3 = FWKEY; // Clear Lock bit _DINT(); for(i=0;i<DataLend;i++) { *FlashPtr = *Data; // Save Data WaitForEnable(); //Busy *FlashPtr++; Data++; } _EINT(); FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCK; // Set LOCK bit WDTCTL = WDT_ARST_1000;//开一秒看门狗 }
如果MCU的某一地址的flash坏了 是否会导致
while((FCTL3 & BUSY) == BUSY); //Busy
无限等待吗?
是有这个可能,因此在设计软件的时候,是不建议设置这种可能无限等待的while的。你可以使用逻辑运算与,包含一个计时的变量,当等待到计时变量为假的时候自动跳过这个检测。