Intro to MSP430 Flash
The MSP430 is capable of programming in-system any single bit, byte or word anywhere in flash memory. Flash can be programmed in-system, even while executing code from Flash and even while the program is executing code from a segment being programmed. A segment does not have to be erased prior to programming, but 1`s can only be programmed to 0`s.
Erasing is done on complete segments and erases all bit’s in the segment to 1`s. In-system Flash programming or erasing can occur while executing code from Flash, the program counter is automatically stopped during the operation for the duration specified in the device datasheet. As an option, the program counter can be moved to RAM and execute an application program during Flash in-system programming or erasing - in this case code continues to execute full speed, from RAM. Both the information memory and main memory flash areas can be used for either data or code or both. The only difference is that information memory consists of smaller 128 byte segments whereas the main memory consists of 512 byte segments.
The Flash Memory cannot be accessed while it is being programmed or erased. If code is running out of Flash, the code execution will be automatically halted for the duration of the program/erase cycle. If code is running out of RAM and tries to access the Flash memory during a program/erase cycle, a Flash memory access violation will occur.
A higher voltage than the applied Vcc is not required to program flash, though there is a restricted Vcc minimum specified in the device datasheet.
Writing to MSP430 Flash
Using block-write (BLKWRT) mode
The following are few important points mentioned about block write mode:
- Block write BLKWRT mode is used to program the Flash in block sizes of 64-bytes.
- Selecting this mode accelerates the time to program a byte or word of Flash.
- This feature can be used in a system only if the code that does the BLKWRT is executed out of the RAM.
- The data to be written to the Flash should also be in the RAM area.
- During the BLKWRT phase, the user code must never access the Flash memory module for any reason, otherwise an access violation occurs and the ACCVIFG is set.