//FLASH操作 写入
void write_SegC(char value[], char lenChar)
{
char *Flash_ptr; // Flash pointer
char i;
Flash_ptr = (char *) 0x1040; // Initialize Flash pointer
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
*Flash_ptr = 0; // Dummy write to erase Flash segment
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
for (i = 0; i < lenChar; i++)
{
*Flash_ptr++ = value[i]; // Write value to flash
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
}
//FLASH操作 读取
void read_SegC(char value[], char lenChar)
{
char *Flash_ptrC; // Segment C pointer
char i;
Flash_ptrC = (char *) 0x1040; // Initialize Flash segment C pointer
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
for (i = 0; i < lenChar; i++)
{
value[i] = *Flash_ptrC++; // copy value
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
}
来源:CSDN
作者:x1131230123
链接:https://blog.csdn.net/x1131230123/article/details/104541490