Tool/software: Code Composer Studio
Hello you,
I have problem with my project, i need save information to flash. but i can not erase. this is my code:
void write_InfoSeg(char value) { unsigned char *Flash_ptr; // Flash pointer unsigned int i; __disable_interrupt(); Flash_ptr = (unsigned char *)SEGSTART; // Initialize Flash pointer if(FCTL3 & LOCKSEG) { // If Info Seg is stil locked FCTL3 = FWKEY | LOCKSEG; // Clear LOCKSEG bit } while(BUSY & FCTL3); FCTL3 = FWKEY; // Clear Lock bit FCTL1 = FWKEY+ERASE; // Set Erase bit while ((FCTL3 & BUSY) == BUSY); FCTL1 = FWKEY | WRT; // Set WRT bit for write operation for (i = 0; i < SEG_LEN; i++) { *Flash_ptr++ = value; // Write value to flash } FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY | LOCKSEG; // Set LOCKSEG bit __enable_interrupt(); }
Thanks