Lab 10: Programming the Flash
TMS320F2837xD Microcontroller Workshop - System Design 10 - 17
F2837xD_GlobalVariableDefs.c
F2837xD_Headers_nonBIOS_cpu1.cmd
Note: The Flash.c file will be added during the lab exercise.
Link Initialized Sections to Flash
Initialized sections, such as code and constants, must contain valid values at device power-up.
Stand-alone operation of an embedded system means that no debug probe (emulator) is
available to initialize the device RAM. Therefore, all initialized sections must be linked to the on-
chip flash memory.
Each initialized section actually has two addresses associated with it. First, it has a LOAD
address which is the address to which it gets loaded at load time (or at flash programming time).
Second, it has a RUN address which is the address from which the section is accessed at
runtime. The linker assigns both addresses to the section. Most initialized sections can have the
same LOAD and RUN address in the flash. However, some initialized sections need to be loaded
to flash, but then run from RAM. This is required, for example, if the contents of the section
needs to be modified at runtime by the code.
2. Open and inspect the linker command file Lab_10.cmd. Notice that the first flash sector
has been divided into two blocks named BEGIN_FLASH and FLASH_A. The FLASH_A
flash sector origin and length has been modified to avoid conflicts with the other flash
sector spaces. The remaining flash sectors have been combined into a single block
named FLASH_BCDEFGHIJKLMN. See the reference slide at the end of this lab
exercise for further details showing the address origins and lengths of the various flash
sectors used.
3. Edit Lab_10.cmd to link the following compiler sections to on-chip flash memory block
FLASH_BCDEFGHIJKLMN:
Compiler Sections:
.text .cinit .const .econst .pinit .switch
Copying Interrupt Vectors from Flash to RAM
The interrupt vectors must be located in on-chip flash memory and at power-up needs to be
copied to the PIE RAM as part of the device initialization procedure. The code that performs this
copy is located in InitPieCtrl(). The C-compiler runtime support library contains a memory copy
function called memcpy() which will be used to perform the copy.
4. Open and inspect InitPieCtrl() in PieCtrl.c. Notice the memcpy() function used to
initialize (copy) the PIE vectors. At the end of the file a structure is used to enable the
PIE.