⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccstutorial.m

📁 matlab连接ccs的例子
💻 M
📖 第 1 页 / 共 3 页
字号:
% CCSTUTORIAL Link for CCS(tm) tutorial.
%   CCSTUTORIAL is an example script intended to get the user started with
%   the 'Link for Code Composer Studio(tm) IDE'.  A simple target DSP 
%   application is loaded and run  on the target DSP.  Memory reads/writes 
%   are demonstrated. Methods that are demonstrated include
%  Global Commands -
%     ccsboardinfo, boardprocsel, ccsdsp, clear
%  CCSDSP object methods - 
%     visible,disp,info,isrunning,address,halt,run,restart,read,write
%     regread,regwrite,createobj,visible,insert.
%  Data object-methods-
%     numeric   - read,write,cast
%     string    - read,write
%     structure - read,write,getmember
%     enum      - read,write,readnumeric
%
%    See also RTDXTUTORIAL, CCSFIRDEMO, RTDXLMSDEMO, CCSDSP

%   Copyright 2001-2002 The MathWorks, Inc.
%   $Revision: 1.17 $  $Date: 2002/05/24 21:22:45 $
%
%
echo off
% ========================================================================
% Intro
disp(sprintf(['=================================================================\n'...
              ' The ''MATLAB Link for Code Composer Studio'' provides a direct\n'...
              '  connection between MATLAB and a DSP in Code Composer.  This\n'...
              '  provides a mechanism for controlling and manipulating an\n'...
              '  embedded application using the full computational power of\n'...
              '  MATLAB. This can be used to assist DSP debugging and development.\n'...
              '  Another possible use is for creation of MATLAB scripts for\n'...
              '  verification and testing of algorithms that exist in their \n'...
              '  final implementation on an actual DSP target.\n\n'...
              ' Before discussing the methods available with the link object,\n'...
              '  it''s necessary to select a DSPto target.  When the link\n'...
              '  is created, it is specific to a particular CPU, (i.e. a DSP\n'...
              '  processor) so selection is required before proceeding\n'...
              '  In general, the selection process is only necessary \n'...
              '  for multiprocessor configurations of Code Composer Studio.\n'...
              '=================================================================\n\n']));
disp('--- Press any key to continue ---');
pause;

% ========================================================================
% command line board/processor selection command: ccsboardinfo
disp(sprintf(['=================================================================\n'...
              ' The ''MATLAB Link for Code Composer Studio'' provides two tools\n'...
              '  for selecting a DSP board and processor in multiprocessor\n'... 
              '  configurations.  First, a command line version called: ''ccsboardinfo'' \n'...
              '  which generates a list of the available boards and processors.\n'...
              '  For scripting, this command can return a structure, which\n'...
              '  can be applied programmatically to select a particular DSP chip.\n'...
              '=================================================================\n\n']));
disp('--- Press any key to continue:  ccsboardinfo ---');
pause;
echo on
ccsboardinfo
echo off;

% ========================================================================
% GUI board/processor selection tool: boardprocsel
disp(sprintf(['=================================================================\n'...
              ' Another selection option is a GUI tool called ''boardprocsel''.\n'...
              '  Please Note - the CPU that is selected in the GUI will be used\n'...
              '  for the rest of this tutorial.  For single processor installations,\n'...
              '  of Code Composer Studio, simply select ''OK'' from the message box\n'...
              '  to continue.\n'...
              '=================================================================\n\n']));
      
disp('---  Press any key to continue, then select a DSP from the GUI (or click OK):  boardprocsel ---');
pause;
echo on
[boardNum,procNum] = boardprocsel
echo off

if isempty(boardNum) | isempty(procNum),
    disp(sprintf(['The board/processor GUI was canceled without selecting a valid device\n'...
                  ' Please restart the tutorial and select a valid board and processor\n']));
    error('No board or processor selected to create Link' );
else
    fprintf(1,['\n The goal of this selection process is a board number\n'...
              '  and processor number that uniquely identify a particular\n'...
              '  target DSP.  These values are then applied during the link creation.\n\n'...
              ' You selected board number = %d, and processor number = %d\n\n'],boardNum,procNum);
end
%========================================================================
% Object Constructor: ccsdsp
disp(sprintf(['=================================================================\n'...
              ' Next, the actual connection between the MATLAB command line and Code \n'...
              '  Composer will be established.  This link is represented by a MATLAB\n'...
              '  object, which for this session will be saved in variable ''cc''.  The\n'...
              '  link object is created with the ''ccsdsp'' command, which accepts the\n'...
              '  board  number and processor number as input parameters.  Other\n'...
              '  properties can also be defined during the object creation; refer to\n'...
              '  the ''ccsdsp'' documentation for more information on these properties.\n'...  
              '  The generated ''cc'' object will be used to direct actions to the \n'...
              '  designated DSP chip.  Therefore, it will appear in all commands that\n'...
              '  follow the object creation.  Naturally, in multiprocessor \n'...
              '  implementations it is possible to have more than one link object.\n'...
              ' NOTE - Before proceeding, your DSP hardware should be reset and \n'...
              '  configured as needed for operation by Code Code Composer.\n'...
              '=================================================================\n\n']));

disp('--- Press any key to continue:  ccsdsp ---');
pause;
echo on
cc=ccsdsp('boardnum',boardNum,'procnum',procNum)
echo off
%========================================================================
% Visibility of Code Composer
disp(sprintf(['=================================================================\n'...
              ' You may have noticed Code Composer appear briefly when ''ccsdsp''\n'...
              '  was called.  If Code Composer was not running before the link\n'...
              '  is established, it is started and then placed in the background.\n'...
              '  In most cases, you will need to interact with Code Composer,\n'...
              '  so the first method that will be introduced (called ''visible'')\n'...
              '  controls the state of Code Composer on the desktop. This accepts\n'...
              '  a Boolean input that makes Code Composer visible (1) or \n'...
              '  invisible (0) on the desktop.  For the rest of this tutorial, \n'...
              '  we will need to interact with Code Composer, so we''ll use \n'...
              '  ''visible'' to bring it up to the desktop.\n'...
              '=================================================================\n\n']));
echo on
visible(cc,1)  % Force Code Composer to be visible on the desktop
echo off
%========================================================================
% Link Status: info, isrunning, disp
disp(sprintf(['=================================================================\n'...
              ' With the link in place, it is now possible from MATLAB to\n'...
              '  query Code Composer for status on the specified DSP.\n'...
              '  Four methods are available to get status information:  \n'...
              '  ''info'' - returns a structure of testable Target conditions.\n'...
              '  ''disp'' - prints a list of information about the target CPU.\n'...
              '  ''isrunning'' - returns the state (running or halted) of the CPU.\n'...
              '  ''isrtdxcapable'' - reports CPUs ability to perform RTDX(tm) transfers.\n'...
              '  The next segment will demonstrate these methods.\n'...
              '=================================================================\n\n']));
disp('--- Press any key to continue:  info,disp,isrunning ---');
pause;
echo on
disp(cc)
pause(2);   % Wait long enough to see results from disp
linkinfo = info(cc)
cpurunstatus = isrunning(cc)
isrtdxcapable(cc)
echo off

%========================================================================
% Determine family variants (5x or 6x11 or 6x0x?)
familycpu = linkinfo.subfamily;
revisioncpu = linkinfo.revfamily;
c5xfamily = logical(0);
c6x11family = logical(0);
c6x0xfamily = logical(0);
if familycpu >=  hex2dec('50') & familycpu <  hex2dec('60'),
    c5xfamily = logical(1);
elseif familycpu >=  hex2dec('60') & familycpu <  hex2dec('70') & revisioncpu > 10,
    c6x11family = logical(1);
elseif familycpu >=  hex2dec('60') & familycpu <  hex2dec('70'),
    c6x0xfamily = logical(1);
else
    error(' The selected family of DSPs is NOT supported by this product');
end
disp(sprintf(['From the ''subfamily'' and ''revfamily'' members of the structure\n'...
              ' returned by the ''info'' method, it was determined that you selected\n'...
              ' a TMS%03dC%2s%02d DSP.\n'...
              'Please note - In some cases, the values reported by Code Composer\n'...
              ' do not match the physical device numbering scheme.\n\n'],...
              linkinfo.family,dec2hex(linkinfo.subfamily),linkinfo.revfamily));
    
%========================================================================
% The Code Composer Files: load/open

disp(sprintf(['=================================================================\n'...
              ' Now that a connection has been established, the target CPU needs\n'...
              '  something to do!  Therefore, the next step is to create executable \n'...
              '  code for the target DSP with Code Composer. For this tutorial, a\n'...
              '  Code Composer project file was created and included with MATLAB. \n'...
              '  The following set of commands will locate the tutorial project\n'...
              '  file and load it into Code Composer.  This will use the ''open''\n'...
              '  method, which can direct Code Composer to load a project files\n'...
              '  or program file. \n'...
              '=================================================================\n\n']));
disp('--- Press any key to continue:  open,cd ---');
pause;
if c5xfamily,
echo on
projfile = fullfile(matlabroot,'toolbox','ccslink','ccsdemos','ccstutorial','ccstut_54xx.pjt')
projpath = fileparts(projfile)
open(cc,projfile)     % Open project file
cd(cc,projpath)       % Change working directory of Code Composer(only)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -