EmbeddedRelated.com
Forums

Erasing main flash segments

Started by Robert January 10, 2012
Maybe this is obvious, but I want to make sure I understand. We're using an MSP430F5438A, and are writing a custom bootloader to update the application. I thought I could erase the main flash by segment, but the documentation only refers to bank erases for main memory. It doesn't say you cannot erase by segment.

Must I erase the main flash by bank only? If so, this really complicates things because the ISRs for the app and BL need to be in low memory, but low memory is all contained in 1 bank.

I'd appreciate any insight.

- Bob

Beginning Microcontrollers with the MSP430

You can erase by segment. That is how I do it for the F148/F149/F2418/F5418/F5418A.

void Flash_Erase_Segment( INT_PTR Data_ptr )
{
while ( FCTL3 & BUSY )
{
}
FCTL3 = FWKEY ;
FCTL1 = FWKEY + ERASE ; /* ERASE = 1 */
*Data_ptr = 0 ; /* erase Flash segment */
FCTL1 = FWKEY ; /* ERASE = 0 */
FCTL3 = FWKEY + LOCK ;
while ( FCTL3 & BUSY ) /* Required if the segment being erased is not in the */
{ /* current execution bank (change for the F5xxx series */
}
}
Ian

From: m... [mailto:m...] On Behalf Of Robert
Sent: 10 January 2012 16:59
To: m...
Subject: [msp430] Erasing main flash segments

Maybe this is obvious, but I want to make sure I understand. We're using an MSP430F5438A, and are writing a custom bootloader to update the application. I thought I could erase the main flash by segment, but the documentation only refers to bank erases for main memory. It doesn't say you cannot erase by segment.

Must I erase the main flash by bank only? If so, this really complicates things because the ISRs for the app and BL need to be in low memory, but low memory is all contained in 1 bank.

I'd appreciate any insight.

- Bob