Lab 12: Programming the Flash
12 - 16
C2000 Microcontroller Workshop - System Design
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.
5.
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.
Initializing the Flash Control Registers
The initialization code for the flash control registers cannot execute from the flash memory (since
it is changing the flash configuration!). Therefore, the initialization function for the flash control
registers must be copied from flash (load address) to RAM (run address) at runtime. The memory
copy function
memcpy()
will again be used to perform the copy. The initialization code for the
flash control registers InitFlash() is located in the
Flash.c
file.
6.
Add
Flash.c
to the project.
7.
Open and inspect
Flash.c
. The C compiler CODE_SECTION pragma is used to place
the
InitFlash()
function into a linkable section named “
secureRamFuncs
”.
8.
The “
secureRamFuncs
” section will be linked using the user linker command file
Lab_12.cmd
. Open and inspect
Lab_12.cmd
. The “
secureRamFuncs
” will load
to flash (load address) but will run from
L4SARAM
(run address). Also notice that the
linker has been asked to generate symbols for the load start, load size, and run start
addresses.
While not a requirement from a MCU hardware or development tools perspective (since
the C28x MCU has a unified memory architecture), historical convention is to link code
to program memory space and data to data memory space. Therefore, notice that for the
L4SARAM
memory we are linking “
secureRamFuncs
” to, we are specifiying “PAGE
= 0” (which is program memory).
9.
Open and inspect
Main_12.c
. Notice that the memory copy function memcpy() is
being used to copy the section “
secureRamFuncs
”, which contains the initialization
function for the flash control registers.
10.
Add a line of code in
main()
to call the
InitFlash()
function. There are no passed
parameters or return values. You just type
InitFlash();
at the desired spot in
main()
.
Code Security Module and Passwords
The CSM module provides protection against unwanted copying (i.e. pirating!) of your code from
flash, OTP memory, and the L0, L1, L2, L3 and L4 RAM blocks. The CSM uses a 128-bit
password made up of 8 individual 16-bit words. They are located in flash at addresses 0x3F7FF8
Summary of Contents for C2000 Piccolo LaunchPad
Page 74: ...Interrupts 4 18 C2000 Microcontroller Workshop Reset and Interrupts ...
Page 100: ...Lab 5 System Initialization 5 26 C2000 Microcontroller Workshop System Initialization ...
Page 218: ...Lab 8 IQmath FIR Filter 8 42 C2000 Microcontroller Workshop Numerical Concepts ...
Page 334: ...F28069 controlCARD A 4 C2000 Microcontroller Workshop Appendix A Experimenter s Kit SW2 ...
Page 336: ...F28035 controlCARD A 6 C2000 Microcontroller Workshop Appendix A Experimenter s Kit SW2 SW3 ...