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.

MSP430F4250的信息区Flash读写问题

Other Parts Discussed in Thread: MSP430F4250

用了MSP430F4250对信息区的地址0x1040地址写数据并读取,结果好像写不进去,单步调试或者直接运行,在WATCH中看到这个地址的值一直是0xff,不知道什么原因,哪位高手帮忙看看,谢谢。

晶振是4M。

void main(void)
{

    WDTCTL = WDTPW + WDTHOLD; 
    FLL_CTL0 |= XTS_FLL; //设置振荡器为高频,4M
    FLL_CTL0 |= XCAP0PF; //设置内部晶体匹配电容为0PF
    SCFQCTL = SCFQ_64K; //设置MCLK=SMCLK=2*ACLK;
    FCTL2=FWKEY+FSSEL1+FN3+FN1;//FLASH时钟设置,选在MCLK,11分频,大约364K

   char value=26;

   char value_m=0;

   char *data_ptr;
   data_ptr=(char *)0x1040;
   if(*data_ptr==0xff)
       write_SegC(value);
  else
    value_m = *data_ptr;

}

void write_SegC(char value)
{
    char *Flash_ptr; // Flash pointer
    Flash_ptr = (char *)0x1040; // Initialize Flash pointer
     FCTL3 = FWKEY; // Clear Lock bit
    FCTL1 = FWKEY + ERASE; // Set Erase bit
    *Flash_ptr = 0; // Dummy write to erase Flash seg
    FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
    *Flash_ptr++ = value; // Write value to flash
    FCTL1 = FWKEY; // Clear WRT bit
    FCTL3 = FWKEY + LOCK; // Set LOCK bit
}