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

mpc555_mtrctrl_getclock(block, base_clock, module)
%------------------------------------------------------------------
% FUNCTION [CLOCK, CLOCKVALID] = MPC555_MTRCTRL_GETCLOCK(BLOCK)
%
% Get the clock frequency for the appropriate TCR1 or TCR2 clock
%------------------------------------------------------------------
function [clock,clockvalid] = mpc555_mtrctrl_getclock(block, base_clock, module)

% find the clock speeds for the appropriate TPU module
try
    target = RTWConfigurationCB('get_target', block);
catch
    % NOTE: we only end up here if there is no config
    % block in the model.
    clock = 0;
    clockvalid = false;
    return;
end;

config = target.findConfigForClass('MPC555dkConfig.TPU');

if nargin == 2 || nargin == 1
    module = get_param(block, 'module');
end

if nargin == 1
    base_clock = get_param(block,'base_clock');
end

switch base_clock
    case 'TCR1'
        clock = eval(['config.TPU_' module '.TCR1.TCR1_Clock_Frequency']);
        clockvalid = true;
    case 'TCR2'
        if strcmp(eval(['config.TPU_' module '.TCR2.TCR2_Counter_Clock_Source']),'Gated IMB clock')
            clock = eval(['config.TPU_' module '.TCR2.TCR2_Clock_Frequency']);
            clockvalid = true;
        else
            clock = 0;
            clockvalid = false;
        end
end
end

Contact us