Lab 10: Programming the Flash
TMS320F2837xD Microcontroller Workshop - System Design 10 - 19
Therefore, assembly code must be used for the branch. We are using the assembly code file
named CodeStartBranch.asm.
10. Open and inspect CodeStartBranch.asm. This file creates an initialized section
named “codestart” that contains a long branch to the C-environment setup routine. This
section needs to be linked to a block of memory named BEGIN_FLASH.
11. In the earlier lab exercises, the section “codestart” was directed to the memory named
BEGIN_M0. Edit Lab_10.cmd so that the section “codestart” will be directed to
BEGIN_FLASH. Save your work.
On power up the reset vector will be fetched and the ROM bootloader will begin execution. If the
emulator is connected, the device will be in emulation boot mode and will use the EMU_KEY and
EMU_BMODE values in the PIE RAM to determine the boot mode. This mode was utilized in the
previous lab exercises. In this lab exercise, we will be disconnecting the emulator and running in
stand-alone boot mode (but do not disconnect the emulator yet!). The bootloader will read the
OTP_KEY and OTP_BMODE values from their locations in the OTP. The behavior when these
values have not been programmed (i.e., both 0xFF) or have been set to invalid values is boot to
flash boot mode.
Initializing the CLA
Previously, the named section “Cla1Prog” containing the CLA program tasks was linked directly
to the CPU memory block RAMLS4 for both load and run purposes. At runtime, all the code did
was map the RAMLS4 block to the CLA program memory space during CLA initialization. For an
embedded application, the CLA program tasks are linked to load to flash and run from RAM. At
runtime, the CLA program tasks must be copied from flash to RAMLS4. The memory copy
function memcpy() will once again be used to perform the copy. After the copy is performed, the
RAMLS4 block will then be mapped to CLA program memory space as was done in the earlier
lab.
12. In Lab_10.cmd notice that the named section “Cla1Prog” will now load to flash (load
address) but will run from RAMLS4 (run address). The linker will also be used to
generate symbols for the load start, load size, and run start addresses.
13. Open Cla_10.c and notice that the memory copy function memcpy() is being used to
copy the CLA program code from flash to RAMLS4 using the symbols generated by the
linker. Just after the copy the MemCfgRegs structure is used to configure the RAMLS4
block as CLA program memory space. Close the opened files.
Build – Lab.out
14. Click the “Build” button to generate the Lab.out file to be used with the CCS Flash
Programmer. Check for errors in the Problems window.
Programming the On-Chip Flash Memory
In CCS the on-chip flash programmer is integrated into the debugger. When the program is
loaded CCS will automatically determine which sections reside in flash memory based on the
linker command file. CCS will then program these sections into the on-chip flash memory.
Additionally, in order to effectively debug with CCS, the symbolic debug information (e.g., symbol
and label addresses, source file links, etc.) will automatically load so that CCS knows where
everything is in your code. Clicking the “Debug” button in the CCS Edit perspective will
automatically launch the debugger, connect to the target, and program the flash memory in a
single step.