<< Chapter < Page Chapter >> Page >
Using the MSP-EXP430FG4618 Development Tool implement a flash memory programming with the CPU executing the code in RAM.

Laboratory flash memory: lab2 - flash memory programming with the cpu executing the code in ram


The TI MSP430 has an internal flash memory that can be used for data storage. Two different methods of writing to the flash memory are studied in this laboratory. The first method requires the CPU execution of the code resident in flash memory. The consequences of this procedure are discussed. In the second part of the laboratory, the flash write and erase operations are conducted with the CPU executing the code resident in RAM. The important details are highlighted.


This laboratory programs the internal flash memory with the CPU executing the code in RAM. It requires to configure: - Several flash storage management routines; - Check the state of the flag Wait; an the - Flash write routine. This procedure requires special attention during the project construction. The application begins copying the routines from flash to RAM. Directive MEMORY: Device's memory configuration. Identifies the memory ranges that are physically present on the device Directive SECTIONS: controls how the sections are built and reserved.

The execution time of the different operations can be obtained with an oscilloscope connected on pin 2 of the Header 4 or analyzing the state of the LED (digital output P2.1).


The tasks developed in the Lab1: Flash memory programming with the CPU executing the code from flash memory are executed again during this laboratory. The difference this time is that the software runs from RAM.

This process requires special procedures. The routines to run from RAM must be identified. The application must begin by copying the routines from flash to RAM.

The directive MEMORY determines the device's memory configuration. The memory can be organized in accordance with the system needs. This directive identifies the memory ranges that are physically present on the device. Each of these ranges has a set of features, such as:

- Name;

- Initial address;

- Length;

- Optional attributes set;

- Optional filling specifications.

The directive Memory is organized as described below.

MEMORY {name 1 [(attr)] : origin = constant, length = constant [, fill = constant]name n [(attr)]: origin = constant, length = constant [, fill = constant] }

The directive SECTIONS controls how the sections are built and reserved. The directive performs the following:

- Describes how the input sections are related to the output sections;

- Defines the output sections in the executable program;

- Defines where the output sections are placed in memory;

- Allows changing the name of the output sections;

The directive SECTIONS is organized as described below.

SECTIONS {name : [property [, property] [, property]. . . ] name : [property [, property][, property] . . . ]name : [property [, property] [, property]. . . ] }The following directives are possible:// Reserve memory space to load the section: Syntax: load = allocation orAllocation or>allocation// Define the memory space where the code belonging to the section will run:Syntax: run = allocation or run>allocation

In this project, we intend to write the code to the flash memory, but we want it to be executed from RAM. The Linker offers a very simple way to accomplish this task. A memory space where the code is stored is associated with another memory space where it will run. The application transfers the code to the memory space, where it will be executed.

The memory spaces needed to store the routines are defined in the lnk_msp430fg4618_RAM.cmd file.

RAM_MEM : origin = 0x1100, length = 0x0200 FLASH_MEM : origin = 0x3100, length = 0x0200

The following sections are also defined:


Software application organization

The software for this laboratory has the same structure as the Lab1: Flash memory programming with the CPU executing the code from flash memory .

The directive #pragma CODE_SECTION (symbol, "section name") reserves space for the " symbol " in a section called " section name ". Thus, the routines are stored in the section " .FLASHCODE ".

The routine copy_flash_to_RAM runs from the beginning of the program. It is responsible for transferring the flash contents to RAM.

The files ( Lab2_Flash.c ) and lnk_msp430fg4618_RAM.cmd must be included during the compilation.

Now, the code is executed from RAM. Check, whenever appropriate, the Wait bit state of the register FCTL3.

System configuration

Flash storage management routines

To store the flash management routines in the section ".FLASHCODE" complete the empty spaces:

#pragma CODE_SECTION(erase_segment,".FLASHCODE") void erase_segment(int address)#pragma CODE_SECTION(write_char_flash,".FLASHCODE")void write_char_flash(int address, char value)#pragma CODE_SECTION(write_int_flash,".FLASHCODE") void write_int_flash(int address, int value)#pragma CODE_SECTION(copy_seg_flash,".FLASHCODE")void copy_seg_flash(int address_source, int address_destination)

Check the flag wait

At software key points, and whenever writing or erasing the flash memory, perform a delay before proceeding with the data writes. Complete the following line of code in order to suspend the program flow while the busy flag is not active.

while(FCTL3&BUSY); // Check BUSY flag

Analysis of operation

Analyse the differences between the different versions of the routines. Note that successive delays are placed in the versions to be executed from RAM.

This example and many others are available on the MSP430 Teaching ROM.

Request this ROM, and our other Teaching Materials here (External Link)

Questions & Answers

are nano particles real
Missy Reply
Hello, if I study Physics teacher in bachelor, can I study Nanotechnology in master?
Lale Reply
no can't
where we get a research paper on Nano chemistry....?
Maira Reply
nanopartical of organic/inorganic / physical chemistry , pdf / thesis / review
what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
Application of nanotechnology in medicine
has a lot of application modern world
what is variations in raman spectra for nanomaterials
Jyoti Reply
ya I also want to know the raman spectra
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
yes that's correct
I think
Nasa has use it in the 60's, copper as water purification in the moon travel.
nanocopper obvius
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
how nano science is used for hydrophobicity
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
what is differents between GO and RGO?
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
analytical skills graphene is prepared to kill any type viruses .
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now

Source:  OpenStax, Teaching and classroom laboratories based on the “ez430” and "experimenter's board" msp430 microcontroller platforms and code composer essentials. OpenStax CNX. May 19, 2009 Download for free at http://cnx.org/content/col10706/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Teaching and classroom laboratories based on the “ez430” and "experimenter's board" msp430 microcontroller platforms and code composer essentials' conversation and receive update notifications?