NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

LAUNCHXL2 TMS57012: Project 0

From Texas Instruments Wiki
Jump to: navigation, search

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).

Code Composer Studio Installation

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):

Hercules DeviceSupport.PNG

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)

Hercules LaunchPad XDS100 Install.PNG

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):

Updating ccs for xds110.png

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 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.
    CCS Edit Perspective Selected (Click To Enlarge)
  3. From the CCS Menu, select File->New->Target Configuration File
    New Target Configuration File (Click to Enlarge)
  4. Give the Target Configuration File an Appropriate Name. For example LAUNCHXL2-RM46.ccxml or LAUNCHXL2-TMS57012.ccxml
  5. Select Texas Instruments XDS110, XDS-ET USB Debug Probe as the Connection
  6. Select the correct target device. For LAUNCHXL2-TMS57012 this is TMS570LS1224. For LAUNCHXL2-RM46 this is RM46L852.
    LAUNCHXL2-RM46 Target Configuration (Click to Enlarge)
    LAUNCHXL2-TMS57012 Target Configuration (Click to Enlarge)
  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 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 window
  12. Confirm that the all the tests have passed.
    Example of Test Connections Passing
  13. Close the Test Connections 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.)


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->Target Configurations
    View Target Configurations Menu Item (Click to Enlarge)
  3. Right click on target file that you created in Step 4 to bring up the context menu and select 'Launch Selected Configuration'
    Launching Selected Configuration (Click to Enlarge)
  4. A debug session should open, but with the target disconnected. Right click on the target and select the 'Connect Target' menu item.
    Connect to Your Target
  5. When the target is connected, you can open a memory window and/or a disassembly window (through the CCS menu select View->Memory Browser or View->Disassembly. 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.
    CCS Connected (Click to Enlarge)

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 HalCoGen and Safety Diagnostics Library components during HalCoGen installation. The F021 Flash API component is recommended but not required. The Platform F035 Flash API component is not required for this LaunchPad.

Hercules HalCoGen Install Options.PNG

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 File->New->CCS Project
    Create a New CCS Project (Click to Enlarge)
  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.
    New CCS Project Window for LAUNCHXL2-RM46 (Click To Enlarge)
    New CCS Project Window for LAUNCHXL2-TMS57012 (Click to Enlarge)
  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.)
    New Project Result - For TMS57012 Launchpad (Click to Enlarge)
  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 File->New->Project
  2. In the New Project 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. Make sure to select the PGE suffix, 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. Un-Check "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.

HalCoGen New Project Wizard - Configured for LAUNCHXL2-TMS57012 Project 0
HalCoGen New Project Wizard - Configured for LAUNCHXL2-RM46 Project 0

Configure the Device Initialization Code with HalCoGen

Lets examine the 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].

Launchxl2-rm46-tms57012-leds.PNG

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.
    Driver Enable - for LAUNCHXL2-TMS57012 (click to enlarge)
  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.
    GIOB configuration
  3. From the HalCoGen main menu, save the project file. File->Save Project
  4. From the HalCoGen main menu, generate the driver code. File->Generate Code

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...)

Updated CCS Project Showing HalCoGen Generated Code


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.

sys_main.c viewed in the CCS Project Explorer (in the source folder)

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:
<syntaxhighlight lang='c'> /* USER CODE BEGIN (0) */ /* USER CODE END */

/* Include Files */

  1. include "sys_common.h"

/* USER CODE BEGIN (1) */

  1. include "gio.h"

/* USER CODE END */

/** @fn void main(void)

  • @brief Application main function
  • @note This function is empty by default.
  • This function is called after startup.
  • The user can use this function to implement the application.
  • /

/* USER CODE BEGIN (2) */

  1. define DELAY_VALUE 1000000

/* USER CODE END */

void main(void) { /* USER CODE BEGIN (3) */ int i;

gioInit();

for (;;) { gioToggleBit(gioPORTB, 1); for (i = 0; i < DELAY_VALUE; i++); } /* USER CODE END */ }

/* USER CODE BEGIN (4) */ /* USER CODE END */ </syntaxhighlight>


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.

Project Properties

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.

Add the include folder to the project 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:

Debug Tool

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

Project 0 - Stopped at main()

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:

File:Launchxl2-tms57012-proj0-files.zip

File:Launchxl2-rm46-proj0-files.zip

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 File->Import
    Importing Project 0 Archive (.zip) file - Step 1
  2. When the Import dialog opens, select CCS Projects from under Code Composer Studio
    Importing Project 0 Archive (.zip) file - Step 2
  3. When the Import CCS Eclipse Projects 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
Importing Project 0 Archive (.zip) Steps 3-6