CrossStudio's New Project Wizard simplifies the creation of projects for the TI TMS470 by creating a project with the appropriate project settings, memory map files and startup files. See Creating a New Project for more information on creating projects.

##### To create a new TI TMS470 project

- Select the File | New | New Project menu item.
- Select TI | TMS470 Projects from the Project Type list.
- Select the required project template type from the Templates list.
- Set the required project name and location directory.
- Click OK.

CrossStudio for ARM supports the TI TMS470 running applications from both RAM and FLASH.

##### To build and debug an application running from RAM

- Select the project to work on by using the Project | Set Active Project menu option.
- Select the RAM configuration you require by using the Build | Set Active Build Configuration menu option.
- Build the project by using the Build | Build Project menu option.
- Connect to the appropriate target in the target window.
- Download and start debugging the current project by using Debug | Start Debugging.

##### To build and debug an application running from FLASH

- Select the project to work on by using the Project | Set Active Project menu option.
- Select the FLASH configuration you require by using the Build | Set Active Build Configuration menu option.
- Build the project by using the Build | Build Project menu option.
- Connect to the appropriate target in the target window.
- Download and start debugging the current project by using Debug | Start Debugging.

The following sections describe the TI TMS470 support in more detail. See ARM Target Support for more information.

### Memory Map Files

The default memory map file $(StudioDir)/targets/TI_TMS470/TMS470_MemoryMap.xml has been provided. This file is used to describe the memory layout of the target and is used for linking and debugging. The placement of program sections within the memory map for both RAM and FLASH configurations is described by the non-target-specific default memory maps $(StudioDir)/targets/multi_flash_placement.xml and $(StudioDir)/targets/sram_placement.xml.

The Build | Target Processor project property specifies which of the TMS470 family memory map files are used.

The internal FLASH memory has been split into two banks (FLASH1 & FLASH2) in the default memory map. The address range of FLASH1 is 0x10000000 to 0x10001FEF and the address range for FLASH2 is 0x10002000 onwards (the final address is dependant on the hardware). The internal FLASH memory has been split in this way to allow for the FLASH protection keys which reside in the last four words of the first FLASH sector (0x10001FF0 to 0x10001FFF). See FLASH Protection Key Support for more information on the FLASH protection keys. For simplicity the default section placement file for the FLASH configuration ($(StudioDir)/targets/multi_flash_placement.xml) places the exception vectors and startup code in FLASH1 and the rest of the program in FLASH2, this has the disadvantage that a large part of the first (8K) FLASH sector is wasted. Should FLASH space become an issue you can import and modify the FLASH placement file and move sections from the FLASH2 bank to FLASH1 in order to reclaim the lost space.

### Target Startup Code

The default startup code is in $(StudioDir)/targets/TI_TMS470/TMS470_Startup.s. It contains the exception vectors and the default exception handlers. The FLASH version of the code (specified by defining __FLASH_BUILD) is also responsible for configuring memory to match the above memory map and copying the exception vectors into RAM.

### FLASH Protection Key Support

The MCU F05 FLASH module implements a FLASH protection key scheme in order to prevent un-authorized or accidental erasure of the FLASH memory. The scheme uses four 32 bit keys which are located at the end of the first FLASH sector. To unlock the FLASH memory, and therefore permit modification of the FLASH memory, the four keys (which are not visible to the CPU until the FLASH has been unlocked) must be written to the FLASH controller.

By default all of the FLASH keys are assumed to be 0xFFFFFFFF and in order to prevent accidental programming of the keys with unknown values the FLASH loader has code specifically to prevent any writes to the FLASH key region. Should you wish to use the FLASH protection keys you will need to do the following:

1. In your application project, import the default TMS470 startup file $(StudioDir)/targets/TI_TMS470/TMS470_Startup.s, modify the four words labelled by KEY1, KEY2, KEY3 and KEY4 and rebuild your application.
2. Recompile the TMS470 FLASH loader with the C pre-processor definition PERMIT_KEY_WRITE defined in order to allow the loader to overwrite the FLASH protection keys.
3. Download you application to FLASH, the FLASH protection keys should now be programmed with the new values.
4. Recompile the TMS470 FLASH loader with the C pre-processor definitions KEY1_VAL, KEY2_VAL, KEY3_VAL and KEY4_VAL defined with the required key values in order to permit subsequent downloads.