please dont rip this site

TI MSP430 Microcontroller Writing to FLASH

Question: "How can I store a value, let's say 32, to address 0x1040 in the FLASH memory?"

Answer 1: from old_cow_yellow

ORG 0x1040
DB 0x32
END

Answer 2: from Ajesh GUPTA

Flash_ptr = (int *)0x1040;
FCTL3 = FWKEY; // Clear Lock bit
FCTL1 = FWKEY + ERASE; // Set Erase bit
*Flash_ptr = 0; // Dummy write to erase Flash seg
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit

FCTL1 = FWKEY + WRT; // Set WRT bit for write operation
*Flash_ptr = value;
FCTL1 = FWKEY; // Clear WRT bit
FCTL3 = FWKEY + LOCK; // Set LOCK bit

Answer 3: from Darren Logan

first turn OFF interrupts

/* PROCEDURE: write to flash memory ----------------------------------------------------------*/
void FlashWrite(unsigned int faddress, unsigned int word)
{

/* Note this procedure does NOT erase the flash segment before writing the new value.
Writing a new value over an old value does not work as the flash cells will only accept
a written 0 and not a written 1. You must erase the whole segment before writing a new value. */


int *Flash_ptr; /* Flash pointer */

Flash_ptr = (int *) 0x1000 + faddress; /* Initialize Flash pointer (segment B - start of info. memory) */

FCTL1 = FWKEY + ERASE; /* Set Erase bit */
FCTL3 = FWKEY; /* Clear LOCK bit */
FCTL1 = FWKEY + WRT; /* Set WRT bit for write operation */
*Flash_ptr=word; /* Write the word to flash */
FCTL1 = FWKEY; /* Clear WRT bit */
FCTL3 = FWKEY + LOCK; /* Reset LOCK bit */

} /* FlashWrite */

Verifying Flash

To avoid Flash25 bug, do not use @Rn or @Rn+ to read the FLASH during marginal read mode. Use X(Rn) as the source address is ok. (But be aware that most assemblers will change 0(Rn) to @Rn behind your back.

See:


file: /Techref/ti/msp430/flashwrite.htm, 2KB, , updated: 2010/10/27 11:22, local time: 2024/11/19 10:34,
TOP NEW HELP FIND: 
18.118.154.33:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://linistepper.com/Techref/ti/msp430/flashwrite.htm"> MSP430, Microcontroller, FLASH</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?