Part Number: TRF7970A
Other Parts Discussed in Thread: MSP430G2553,
Hello,
We are using the reference firmware provided for TRF7970A and MSP430G2553 and also, we developed a custom board with these ICs mounted on it.
Our issue is that, we are trying to store the details of the tag UUID in info segment of MSP. First we tested the flash erase/write part of the program separately and it worked fine.
But, when tried to combine this program with the reference firmware for TRF7970A, we found that the flash write is happening as desired. In few boards it is corrupt data while in few it is proper.
We tried to figure but couldn't so far. Can please help in this issue.
TIA.
Below is the code for flash write we are using:
//================================================================
// Flash erase
//================================================================
void FlashErase(uint8_t *addr)
{
__disable_interrupt(); // Disable interrupts. This is important, otherwise,
// a flash operation in progress while interrupt may
// crash the system.
while(BUSY & FCTL3); // Check if Flash being used
FCTL2 = FWKEY + FSSEL_1 + FN3; // Clk = SMCLK/4
FCTL1 = FWKEY + ERASE; // Set Erase bit
FCTL3 = FWKEY; // Clear Lock bit
*addr = 0; // Dummy write to erase Flash segment
while(BUSY & FCTL3); // Check if Flash being used
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
__enable_interrupt();
}
//=================================================================
// Flash write
//=================================================================
void FlashWrite(uint8_t *addr, uint8_t *value, uint8_t size)
{
__disable_interrupt();
FCTL2 = FWKEY + FSSEL_1 + FN0; // Clk = SMCLK/4
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
uint8_t ui8LoopCount;
for (ui8LoopCount = 0; ui8LoopCount < size; ui8LoopCount++)
{
*(addr + ui8LoopCount) = value[ui8LoopCount]; // copy value to flash
}
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit
while(BUSY & FCTL3);
__enable_interrupt();
}
Regards,
Maddineni