Part Number: MSP430G2452
MSP team,
This customer is storing some calibration data in their INFO C memory space on MSP430G2452. First they copy the old data to RAM, then test the memory by writing all 0 to a section. They find that 5% of their boards are showing a failure when they read back the 0’s. (Some values are still 1).
They retest on the same board, and it will continue to fail.
Can you look at the code below and see if it looks good? Is it possible delays they’ve inserted are not sufficient or are in the wrong place?
volatile uint16_t *Flash_ptr; // Flash pointer
volatile uint16_t i;
volatile uint16_t backup[INFO_C_SIZE];
uint16_t Backup_Calib, Backup_IR_power;
// Backup INFO C memory prior to erase
Flash_ptr = (uint16_t *) 0x1040; // Initialize Flash pointer
// Backup INFO C memory prior to test
Flash_ptr = (uint16_t *) 0x1040; // Initialize Flash pointer
Backup_Calib = *(Flash_ptr + TRIGGER_VALUE_OFFSET);
Backup_IR_power = *(Flash_ptr + IR_POWER_VALUE_OFFSET);
//Initialize array of 0's
for (i=0; i<INFO_C_SIZE; i++ )
backup[i] = 0;
// Initiate segment erase operation
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
// Write INFO C memory block with array of 0's
Flash_ptr = (uint16_t *) 0x1040; // Initialize Flash pointer again
for (i=0; i<INFO_C_SIZE; i++ )
*Flash_ptr++ = backup[i];
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
wAclkIntrvlTmr_t0(250); // ensure a min delay between writes per data sheet (83.333us per count)
// Read back INFO C memory and verify all addresses are 0's
for (i=0; i<INFO_C_SIZE; i++ ){
if (0 != (read_SegC_TrigVal (i)))
return(FAIL); // Bad memory detected, exit and alert user
}
// Initiate segment erase operation (default to 0xFFFF)
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
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
wAclkIntrvlTmr_t0(250); // ensure a min delay between writes per data sheet (83.333us per count)
// Read back INFO C memory and verify all addresses are 1's
for (i=0; i<INFO_C_SIZE; i++ ){
if (0xFFFF != (read_SegC_TrigVal (i)))
return(FAIL); // Bad memory detected, exit and alert user
}
// Initiate segment erase operation (default to 0xFFFF)
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
// Write INFO C memory block with array
Flash_ptr = (uint16_t *) 0x1040; // Initialize Flash pointer again
// Restore Backup parameters if memory is good
*(Flash_ptr + TRIGGER_VALUE_OFFSET) = Backup_Calib;
*(Flash_ptr + IR_POWER_VALUE_OFFSET) = Backup_IR_power;
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
wAclkIntrvlTmr_t0(250); // ensure a min delay between writes per data sheet (83.333us per count)
return (SUCCESS);
Thanks,
Darren