Code covered by the BSD License  

Highlights from
MPC555 Motor Control Function Blockset

MPC555 Motor Control Function Blockset

by

 

20 Mar 2006 (Updated )

Additional I/O blocks for MPC555 target - specifically targetting TPU functionality

install_mpc555_mtrctrl_blockset()
function install_mpc555_mtrctrl_blockset()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% INSTALL_MPC555_MTRCTRL_BLOCKSET()
%%
%% Install the MPC555_MTRCTRL blockset, and copy in the appropriate
%% source files required for full functionality
%%
%% Example:
%%          install_mpc555_mtrctrl_blockset
%%

newline = sprintf('\n');
thisFile = mfilename('fullpath');
[thisPath,thisName] = fileparts(thisFile);

disp('The mpc555_mtrctrl blockset will be installed in the current directory');
disp(pwd);
a = '';
while ~(strcmp(upper(a), 'Y') || strcmp(upper(a), 'N'))
    a = input('Continue?  (Y/N)','s');
end

if strcmp(upper(a), 'N')
    return;
end

disp(newline);
disp('Do you wish to locate the TPUMASM microcode compiler and the Freescale motorola source files now?');

a = '';
while ~(strcmp(upper(a), 'Y') || strcmp(upper(a), 'N'))
    a = input('Continue?  (Y/N)','s');
end

if strcmp(upper(a), 'Y')
    disp(newline);
    disp('Locate the TPUMASM.EXE assembler');
    %% Change the working directory to the program files directory
    expectedlocation = fullfile(getenv('PROGRAMFILES'), 'Motorola', 'MPC500_Quick_Start r4.0', 'tools', 'tpu');

    disp(['This is likedly to reside in a location such as', newline, expectedlocation]);
    if exist( expectedlocation , 'dir')
        cd(expectedlocation);
    else
        if exist(getenv('PROGRAMFILES'), 'dir')
            cd(getenv('PROGRAMFILES'));
        end
    end
    
    [filename, pathname] = uigetfile('TPUMASM.EXE', 'Locate the TPUMASM microcode compiler');
    if isequal(filename, 0) || isequal(pathname, 0)
        disp(newline);
        disp('Location of TPUMASM.EXE cancelled');
    else
        if ~exist(fullfile(thisPath, 'microcode'), 'dir')
            mkdir(fullfile(thisPath, 'microcode'));
        end
        if ~exist(fullfile(thisPath, 'microcode', 'assembler'), 'dir')
            mkdir(fullfile(thisPath, 'microcode', 'assembler'));
        end
        if copyfile(fullfile(pathname, filename), fullfile(thisPath, 'microcode', 'assembler'));
            disp('Files copied successfully');
        end
    end
    
    disp(newline);
    disp('Locate a single microcode file from the Motorola ROM mask library');
    disp('(all files in the directory will be copied)');
    expectedlocation = fullfile(getenv('PROGRAMFILES'), 'Motorola', 'MPC500_Quick_Start r4.0', 'src', 'support', 'tpu', 'TpuLib', 'ROM');
    if exist(expectedlocation, 'dir')
        cd(expectedlocation);
    end
    
    [filename, pathname] = uigetfile('*.uc', 'Locate the TPUMASM ROM MASK microcode');
    if isequal(filename, 0) || isequal(pathname, 0)
        disp('Location of standard ROM mask library cancelled');
    else
        if ~exist(fullfile(thisPath, 'microcode'), 'dir')
            mkdir(fullfile(thisPath, 'microcode'));
        end
        if ~exist(fullfile(thisPath, 'microcode', 'src'), 'dir')
            mkdir(fullfile(thisPath, 'microcode', 'src'));
        end
        if copyfile(fullfile(pathname, '*.*'), fullfile(thisPath, 'microcode', 'src'));
            disp('Files copied successfully');
        end
    end
    
    expectedlocation = fullfile(getenv('PROGRAMFILES'), 'Motorola', 'MPC500_Quick_Start r4.0', 'src', 'support', 'tpu', 'TpuLib', 'MC');
    if exist(expectedlocation, 'dir')
        cd(expectedlocation);
    end
    
    disp('Locate a single microcode file from the Motorola MC mask library');
    disp('(all files in the directory will be copied)');
    [filename, pathname] = uigetfile('*.uc', 'Locate the TPUMASM MOTOR CONTROL MASK microcode');
    if isequal(filename, 0) || isequal(pathname, 0)
        disp('Location of motor control mask library cancelled');
    else
        if ~exist(fullfile(thisPath, 'microcode'), 'dir')
            mkdir(fullfile(thisPath, 'microcode'));
        end
        if ~exist(fullfile(thisPath, 'microcode', 'src'), 'dir')
            mkdir(fullfile(thisPath, 'microcode', 'src'));
        end
        if copyfile(fullfile(pathname, '*.*'), fullfile(thisPath, 'microcode', 'src'));
            disp('Files copied successfully');
        end
    end
end

cd(thisPath);

disp('Do you wish to add the following paths to your startup.m file?');
disp(newline);

startupmpaths = {thisPath;
    fullfile(thisPath, 'blockset');
    fullfile(thisPath, 'blockset', 'mfiles');
    fullfile(thisPath, 'tests');
    fullfile(thisPath, 'demos')};

startupmpathstring = '';
for n=1:length(startupmpaths)
    startupmpathstring = [startupmpathstring, 'addpath(''', startupmpaths{n} ,''');', newline];
end

disp(startupmpathstring);

a = '';
while ~(strcmp(upper(a), 'Y') || strcmp(upper(a), 'N'))
    a = input('Continue?  (Y/N)','s');
end

if strcmp(upper(a), 'Y')
    startupmfile = which('startup.m');
    if isempty(startupmfile)
        startupmfile = fullfile(matlabroot, 'work', 'startup.m')
    end
    fid = fopen(startupmfile, 'a');
    fwrite(fid, startupmpathstring);
    fclose(fid);
    
end

disp('Do you wish to add the following paths to your current path now?');
disp(newline);
a = '';
while ~(strcmp(upper(a), 'Y') || strcmp(upper(a), 'N'))
    a = input('Continue?  (Y/N)','s');
end

if strcmp(upper(a), 'Y')
    eval(startupmpathstring);
end
end

Contact us