Template:LAUNCHXL2 TMS57012 RM46 PROJ0 INSTALL

Objective
The objective Project 0 is to build a simple example for the purpose of verifying that you have a working development environment. The project itself will do something very simple (Blink an LED), but you will generate your project files with HalCoGen, and build/launch your project with Code Composer Studio (CCS).

Already have CCSv6 Installed?
If not, skip to Step 1.

Otherwise, if you already have CCS version 6 installed, confirm that you have installed "Hercules Device Support". If you are not sure, check which components are installed by viewing the Installation Details as described in Step 3. If your installation does not include the components Code Composer Studio IDE ARM Components and Hercules Emulation then you will need to perform at least Step 2. If you run the installer from the same version of CCS as you ran with your original installation, you can simply add the missing components by installing on top of your existing installation folder.

Step 1: Download Code Composer Studio
First, you need to download. Download Now

If you have not purchased a CCS license, the Launchpad's on-board XDS110 emulator qualifies for a free limited license (limited for use with XDS100 class debug probes). See the topic Licensing - CCSv6 for more information about this and other licensing options.

Step 2: Install Code Composer Studio
Run the CCS Installer. The installer will ask you to accept the license agreement, select an installation folder, and then present you with various options. The minimum components that must be installed are described next, but feel free to install additional components as needed (in case you are working with other TI processors).

Required 'Processor Support' Options During Installation
During the installation process, you will be presented with options for Processor Support. At a minimum you must select 32-bit ARM MCUs, and its components Hercules Device Support and the TI ARM Compiler, as shown here (click on the image to enlarge):

Required 'Select Emulators' Options During Installation
You must select the XDS100 class emulator support option during installation, as shown here: (click on the image to enlarge)

Recommended 'App Center' Options
GUI Composer supports Hercules Products and is recommended; although it is not used for Project 0 or Project 1.

Step 3: Update the TI Emulators Component of CCS (If Necessary)
The Launchpad's on-board XDS110 Emulator requires an update to the TI Emulators Component of Code Composer Studio. You must have TI Emulators version 5.1.635.0 or later to use the XDS110 emulator. To update your TI Emulators component to the latest version, follow the four step process shown in the figure (click to enlarge to full size):

If you need additional help updating your TI Emulators component (for example, instructions on proxy configuration) see Updating CCS.

Step 4: Create a Target Configuration File for Your Launchpad
Once you have installed CCS and have made sure that you have updated to at least version 5.1.635 of the TI Emulators</I> component, you can create a target configuration file for your launchpad. The target configuration file allows you to connect to your launchpad through CCS and debug the Hercules device.

To create a target configuration file for your launchpad:
 * 1) Launch Code Composer Studio.
 * 2) Make sure you are in the "CCS Edit" perspective and not the "CCS Simple" perspective. Launchxl2-rm46-ccs edit perspective.png ‎
 * 3) From the CCS Menu, select File</I>->New</I>->Target Configuration File</I> 2014-12-09 13-01-13.png ‎
 * 4) Give the Target Configuration File an Appropriate Name.   For example LAUNCHXL2-RM46.ccxml</I> or LAUNCHXL2-TMS57012.ccxml</I>
 * 5) Select Texas Instruments XDS110, XDS-ET USB Debug Probe</I> as the Connection
 * 6) Select the correct target device.  For LAUNCHXL2-TMS57012 this is TMS570LS1224.  For LAUNCHXL2-RM46 this is RM46L852. Launchxl2-rm46-ccxml-creation.png Launchxl2-tms57012-ccxml-creation.png
 * 7) Press the "Save" button to save the configuration file
 * 8) Plug in your Launchpad.  If this is the first time connecting an XDS110 to your PC, the driver should be detected and installed.
 * 9) After the launchpad is correctly detected, press the "Test Connection" button.
 * 10) A Test Connections</I> will open.  The integrity tests will run outputting status to this window.
 * 11) When the test are complete, scroll to the bottom of the Test Connections</I> window
 * 12) Confirm that the all the tests have passed. Launchxl2 tms57012 rm46 test connection.png
 * 13) Close the Test Connections</I> window

If all of the tests passed you have a working Target Configuration file.

(Note: If you selected the wrong Hercules device, for example the TMS570 device for a LAUNCHXL2-RM46 launchpad, the JTAG integrity test will still pass.  But you will have problems when you connect and try to download code in later steps.)</I>

Step 5: Launch A Debug Session
Once you have created your target configuration file, you are ready to try launching a debug session. It is OK that you don't yet have a program to load, we will just test whether or not we can connect to your Hercules device and view its memory.
 * 1) Make sure you have started CCS and your launchpad is still attached to your PC through a USB port.
 * 2) From the CCS menu, select View</I>->Target Configurations</I> View target configs.png
 * 3) Right click on target file that you created in Step 4 to bring up the context menu and select 'Launch Selected Configuration' Launchxl2-rm46-tms57012-launch-target-config.png
 * 4) A debug session should open, but with the target disconnected.  Right click on the target and select the 'Connect Target' menu item. Launchxl2-rm46-tms57012-connect to target.png
 * 5) When the target is connected, you can open a memory window and/or a disassembly window (through the CCS menu select View</I>->Memory Browser</I> or View</I>-><I>Disassembly</I>.  Then type address 0x00 into the address bar and press enter.  You should see the beginning of the on-chip Flash memory.   You can also try address 0x08000000 which is the beginning of the on-chip SRAM.  You can try directly editing the SRAM contents in the Memory Browser Window.  Launchxl2-rm46-ccs connected.png

If you are able to successfully complete these steps, then your CCS installation and launchpad are working. In the next step you will install a tool called HalCoGen to generate most of the device initialization code for your blinky project.

HalCoGen - HAL (Hardware Abstraction Layer) Code Generator Installation
HALCoGen provides a graphical user interface that allows the user to configure peripherals, interrupts, clocks, and other microcontroller parameters. Once the device is configured, the user can generate peripheral initialization and driver code, which can be imported into CCS, IAR Workbench, or Keil uVision.

Download
Download HalCoGen.

Unzip & Run the Installer
The HalCoGen installer is packaged for download in a .zip archive. Unzip the installer to a temporary folder before installing. Then run the HalCoGen installer.

Select Components To Install
At minimum, select both the <I>HalCoGen</I> and <I>Safety Diagnostics Library</I> components during HalCoGen installation. The <I>F021 Flash API</I> component is recommended but not required. The <I>Platform F035 Flash API</I> component is not required for this LaunchPad.

Create a New CCS Project for Project 0
Once you have CCS and HalCoGen both installed, you are ready to begin creating your blinky project!

Begin by creating a new CCS Project for your launchpad. To do this:
 * 1) Open CCS
 * 2) Make sure you are in the "CCS Edit" perspective
 * 3) From the CCS Menu, select <I>File</I>-><I>New</I>-><I>CCS Project</I> Launchxl2 rm46 tms57012 newccsproj.png
 * 4) When the "New CCS Project" window opens, select "Empty Project" as the template.  HalCoGen will provide a main function.  In the target selection field select either TMS570LS1224 (For LAUNCHXL2-TMS57012) or RM46L852 (For LAUNCHXL2-RM46).  Select "Texas Instruments XDS110, XDS-ET USB Debug Probe" for the Connection.   Give your project a name such as "LaunchProj0".   It might be a good idea to check your project settings against the screenshots below to make sure they match, before pressing 'Finish'.  Also make a note of the default location for the project.  You will use this location when you create your HalCoGen project.  Launchxl2-rm46-new-proj.png Launchxl2-tms57012-newproj.png
 * 5) You should see a new project by the name of LaunchProj0 (Or the name you gave the project in the prior step) in the CCS "Project Explorer" window. If you expand this node you will also see that a target configuration file for the device and XDS110 Debug Probe was generated by the New CCS Project Wizard. You can check your result against the image below. (If you are using the LAUNCHXL2-RM46 your result should be similar, but the target configuration file will be named RM46L852.ccxml instead.) Launchxl2-tms57012-newproj result.png
 * 6) Leave CCS open as you continue on to the next step.  (Recommended, but not required).

Create a New HalCoGen Project for Project 0
In this step, you will generate almost all of the code that is required for your blinky project with the HalCoGen tool.


 * 1) Launch HalCoGen, and from the main menu select <I>File</I>-><I>New</I>-><I>Project</I>
 * 2) In the <I> New Project </I> wizard that opens, first select the correct Family:  LAUNCHXL2-TMS57012 = TMS570LS12x  -or-  LAUNCHXL2-RM46 = RM46x
 * 3) Next, select the correct device: LAUNCHXL2-TMS57012 = TMS570LS1224PGE  -or-  LAUNCHXL2-RM46 = RM46L852PGE. <B>Make sure to select the PGE suffix</B>, since the launchpads use the QFP footprint.  Do not pick the BGA footprint (ZWT suffix) by mistake.
 * 4) In the "Name" field give the project a name such as "TMS570LS1224_LP_proj0" or "RM46_LP_proj0".
 * 5) <B>Un-Check</B> "Create directory for Project"
 * 6) In the location dialog, browse to the folder where you created your CCS Project.  Select this folder as the 'Location'
 * 7) Select "Texas Instruments Tools" in the Tools drop-down, because we are creating a CCS based project.

When you complete these steps, your New Project wizard will look like one of the two images below. Once you have confirmed this, press the "OK" button. HalCoGen will then load all of the default settings for the device that you have selected.

Configure the Device Initialization Code with HalCoGen
Lets examine the [[Media:LAUNCHXL2_TMS57012_RM46_REVA.pdf|launchpad schematics]] for a moment. On sheet 10, we can see that the two USER LEDs are connected to pins GIOB[1] and GIOB[2].

We'll write our blinky code to blink the first LED, controlled by GIOB[1]. This is labeled "USER LED A" on the launchpad and is located just to the left of the push-button switch labeled "USER SWITCH A".

When we created our new HalCoGen project by selecting the correct device (either TMS570LS1224PGE or RM48L852PGE), the new project wizard in HalCoGen picks default settings for the part which are almost all useful for our blinky project. We only need to make a few changes before we are ready to generate the device initialization code.

Here are the steps:
 * 1) First, on the "Driver Enable" tab, we can uncheck all of the drivers with the exception of GIO. The image below shows how this is done for the TMS570LS1224PGE;  the procedure is the same for the RM46L852PGE. Launchxl2-tms57012-halcogen driver enable.png
 * 2) Next, select the GIO tab, and check the "DIR" box for Port B, Bit 1 (Controlling GIOB[1]).  This step is shown for TMS570LS1224PGE in the image below, but again the procedure is the same for the RM46L852PGE. Launchxl2-tms57012-hcg-giob-config-proj0.png
 * 3) From the HalCoGen main menu, save the project file.  <I>File</I>-><I>Save Project</I>
 * 4) From the HalCoGen main menu, generate the driver code.  <I>File</I>-><I>Generate Code</I>

That's all that is required. Since you generated code directly into your CCS project folder, you should see the CCS project update as shown in the image below. The source files generated by HalCoGen are located in the 'source' folder. The header files are located in the 'include' folder. The HalCoGen project files (.hcg and .dil) are also stored within the CCS project folder. You can open the .hcg file at any time and make additional changes to the device configuration (but don't do this now...)

Add the Blinky Code to sys_main.c
HalCoGen generates the main function for you in a file called sys_main.c, shown as viewed from CCS in the figure below. Let's add the code needed for blinky into this function.

Now, double click on sys_main.c in CCS to open the file in an editor. Make the following edits:


 * 1) Add #include "gio.h" to the include files, between the first pair (1) of USER CODE comments.
 * 2) Add #define DELAY_VALUE 1000000 between the second pair (2) of USER CODE comments.
 * 3) Add a call to gioInit in main between the third pair (3) of USER CODE comments.  gioInit must be called in order for your setting of GIOB[1] as an output (Checking the DIR box) in the HalCoGen GUI to be applied.
 * 4) Add a loop that calls the gioToggleBit function, toggling bit 1 of gioPORTB.  Insert a simple delay loop between toggles.

Combined, the changes should look like this:

You are now almost ready to build your project.

Test the Project!
Before building the project, you need to add the include folder where HalCoGen outputs it's header files to the compiler include path. To do this, simply right click on the project in the CCS Project Explorer, and select 'Properties' from the context menu.

Next, add the include subdirectory to the search path. We recommend using the workspace and project location variables for portability, i.e. "${workspace_loc:/${ProjName}/include}". The image below shows this path being added to the include search path.

Once these steps are complete, you can use the 'Debug' tool to start a process which will automatically:
 * Build the project
 * Launch a Debug Session
 * Download the .out file into flash
 * Run the project to main

To kick this process off, use the Debug tool as illustrated below:

If the process succeeds, you will see something like this:

Now you just need to press the "Resume" tool (or use the F8 key) to start the LED blinking!

Project Files
In case you wish to simply download the project files, they can be found on the links below:





If you use these files, you can temporarily skip over the steps of installing HalCoGen and creating the CCS Project and HalCoGen Project.

Instead, you can import these archived projects into your CCSv6 workspace as follows:
 * 1) From the CCS Main Menu, select <I>File</I>-><I>Import</I> Launchxl2-rm46-tms570-proj0-import step1.png
 * 2) When the Import dialog opens, select <I>CCS Projects</I> from under <I>Code Composer Studio</I> Launchxl2-rm46-tms570-proj0-import step2.png
 * 3) When the <I>Import CCS Eclipse Projects</I> dialog appears, select the 'Select archive file' radio button
 * 4) Browse to the archive file that you downloaded
 * 5) Project 0 should appear in the Discovered Projects list - check the box for it
 * 6) Press Finish