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 */
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/12/24 21:16,
52.14.173.116: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? <A HREF="http://linistepper.com/techref/ti/msp430/flashwrite.htm"> MSP430, Microcontroller, FLASH</A> |
Did you find what you needed? |