MATLAB Examples

TI_HERCULES_RM48_setup() Sets up Matlab to Target TI RM48 MCUs

This function must be customized and then executed before the target support package for TI RM48 MCUs will run properly. Note: if you are viewing the abbreviated form of this help through the command line 'help' or 'doc' functions, please view the full instructions in HTML format instead. matlab:doc -classic

Contents

License

Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
  Redistributions of source code must retain the above copyright
  notice, this list of conditions and the following disclaimer.
  Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the
  distribution.
  Neither the name of Texas Instruments Incorporated nor the names of
  its contributors may be used to endorse or promote products derived
  from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Setting up the Target for TI RM48 MCUs Package

This document explains the steps required to both customize and run the installation script.

Confirm Prerequisite Software is Installed

The Target for TI RM48 MCUs package is dependent on a number of other Mathworks and TI software products. Before continuing, please make sure that all required prerequisites are installed. The System Requirements section of the Getting Started Guide contains information about installing the prerequisite software packages.

Customize the Setup Script

The setup script contains two functions that you must modify to match the installation paths of the prerequisite software on your host machine. You need to make these modifications before you run the setup script. However, the setup script can be modified and run again in case any of the paths change.

You need to modify these functions to match your host machine:

* TI_HERCULES_RM48_setupToolchain()
* TI_HERCULES_RM48_setupComPort()

You should not need to modify TI_HERCULES_RM48_setup() or TI_HERCULES_RM48_setupPath().

TI_HERCULES_RM48_setup() - No modifications required

You should not need to modify this function at all.

function TI_HERCULES_RM48_setup()
% TI_HERCULES_RM48_setup
%   Adds TI RM48 Target Directories to Matlab Path
%   Stores location of TI Code Generation Tools
%   Copyright 2012 Texas Instruments Inc.
    TI_HERCULES_RM48_setupPath()
    TI_HERCULES_RM48_setupToolchain();
    TI_HERCULES_RM48_setupComPort();
    disp('TI_HERCULES_RM48_setup complete');
end

TI_HERCULES_RM48_setupPath() - No modifications required

This function adds the Target for TI RM48 MCUs package to the matlab path. You should not need to modify this function at all.

Tip: pathtool will display your matlab path and also allow you to easily remove the target package from your path.

function TI_HERCULES_RM48_setupPath()
% TI_HERCULES_RM48_setupPath
%   Adds TI RM48 Target Directories to Matlab Path

    TIRM48Fullpath = mfilename('fullpath');
    [TIRM48Dir, ~] = fileparts(TIRM48Fullpath);

    addpath(TIRM48Dir);
    addpath(fullfile(TIRM48Dir, 'rtw'));
    addpath(fullfile(TIRM48Dir, 'utils'));
    addpath(fullfile(TIRM48Dir, 'doc'));
    addpath(fullfile(TIRM48Dir, 'examples'));
    savepath;

    % Save the installation path of the target as a Matlab preference
    setpref('TI_HERCULES_RM48', 'TARGETDIR',  TIRM48Dir);

end

TI_HERCULES_RM48_setupToolchain() - Modify To Match Host Machine

This function sets up Matlab preferences under the preference group TI_HERCULES_RM48 for the installation paths of Code Composer Studio, the TI ARM C/C++ Compiler, and HalCoGen. This information is used by the builder and launcher methods. Once set, the preferences persist between Matlab sessions until explicitly removed.

You must configure: 'CCSVER', 'CCSPATH', 'CGTVER', 'CGTPATH', 'HCGVER', 'HCGPATH', and 'TCONF'. Refer to the comments in the listing of the script below for information about how to set each preference.

Tip: getpref('TI_HERCULES_RM48') displays the preference group settings and rmpref('TI_HERCULES_RM48') removes them.

function TI_HERCULES_RM48_setupToolchain()

    % Retrieve the location of the target package installation.
    % Note: this preference is set in TI_HERCULES_RM48_setupPath().
    TARGETDIR = getpref('TI_HERCULES_RM48', 'TARGETDIR');

    % Modify CCSVER and CCSPATH to match the installation path of
    % Code Composer Studio on your host machine.
    %
    % EXAMPLE:
    % If the path to the code composer studio executable on your host
    % machine is  'c:\ti\ccsv5\eclipse\ccstudio.exe'
    % Then CCSVER = 'ccsv5' and CCSPATH = 'c:\ti\ccsv5'.
    %
    % NOTE1:
    % CCSVER should be set to match the path, not the actual/full version
    % of Code Composer Studio. (i.e. if Version 5.3 of CCS is installed
    % under 'c:\ti\ccsv5' then set CCSVER = 'ccsv5' -- not 'ccsv5.3')
    %
    % NOTE 2:
    % We use fullfile as an alternative to constructing the path string
    % explicitly as 'c:\ti\ccsv5' but you may use either method.
    %
    CCSVER = 'ccsv5';                                           %MODIFY%
    CCSPATH = fullfile('C:','ti',CCSVER);                       %MODIFY%

    % Modify CGTVER and CGTPATH to match the installation path of
    % the TI ARM C/C++ Compiler on your host machine.
    %
    % These preferences must be configured so that the compiler shell
    % program can be found at CCSPATH\bin\armcl.exe
    CGTVER = 'arm';                                             %MODIFY%
    CGTPATH = fullfile(CCSPATH, 'tools','compiler', CGTVER);    %MODIFY%

    % Modify HCGVER and HCGPATH to match the installation path of
    % the HalCoGen Utility.
    %
    % These preferences must be configured so that the HalCoGen executable
    % program can be found at HCGPATH\HALCOGEN.exe
    %
    % Set HCGVER='' and HCGPATH='' if optional HalCoGen is not installed.
    HCGVER = 'v03.06.00';                                        %MODIFY%
    HCGPATH = fullfile('C:','ti','Hercules','HALCoGen',HCGVER); %MODIFY%

    % TCONF must point to the Code Composer Studio target configuration
    % file (.ccxml) that will be used by the launcher to download the
    % PIL executable onto the target and run it.
    %
    % We have included a basic target configuration file in the target
    % package directory, but you can point to your own configuration file.
    TCONF   = fullfile(TARGETDIR,'src','TI_HERCULES_RM48PilSerial', ...
                       'TI_RM48HDK.ccxml');                %MODIFY%

    % You should not modify any of the following lines:
    setpref('TI_HERCULES_RM48', 'CCSVER',  CCSVER);
    setpref('TI_HERCULES_RM48', 'CCSPATH', CCSPATH);
    setpref('TI_HERCULES_RM48', 'CGTVER',  CGTVER);
    setpref('TI_HERCULES_RM48', 'CGTPATH', CGTPATH);
    setpref('TI_HERCULES_RM48', 'HCGVER', HCGVER);
    setpref('TI_HERCULES_RM48', 'HCGPATH', HCGPATH);
    setpref('TI_HERCULES_RM48', 'TCONF', TCONF);

    % Register the Toolchain With MATLAB
    RefreshToolchainMATFiles();

end

TI_HERCULES_RM48_setupComPort() - Modify To Match Host Machine

This function sets up Matlab preferences under the preference group TI_HERCULES_RM48 for the COM port to use during serial rtiostream PIL simulations.

You must configure 'COMPORT' to match the serial port number that will be used during PIL simulations to carry the XIL protocol. The 'COMPORT' preference must include only the numeric portion of the COM port identifier. For example, if the COM port is COM1, then set the 'COMPORT' string to '1' not 'COM1'.

The baud rate in COMBAUD can be changed but not without also changing the baud rate setting in the HalCoGen startup code that is added to the PIL code during the PIL executable build. This is an advanced customization and is described in the Making Customizations section of the Users Guide

function TI_HERCULES_RM48_setupComPort()
    setpref('TI_HERCULES_RM48', 'COMPORT', '67');
    setpref('TI_HERCULES_RM48', 'COMBAUD', '115200');
end

Run the Customized Script

After making the required customizations for your host machine,

Tip - If you have run TI_HERCULES_RM48_setup once and the function is still in your matlab path, click here: TI_HERCULES_RM48_setup

Check Your Customizations

After you have run the setup script, you can check your customization by running the function TI_HERCULES_RM48_check_setup in the target directory. If you receive a summary message indicating an error is found go back through the previous steps. You can run the TI_HERCULES_RM48_setup function as many times as needed; it overwrites previous settings.

Run Now: TI_HERCULES_RM48_check_setup

Note: The script checks only the very basics - just the existence of a key file (usually executable) in the expected folder. More difficult errors may not be caught. This includes an incorrect COM port. See the Troubleshooting section of the User's Guide for more help.