Code covered by the BSD License  

Highlights from
MPC555 Motor Control Function Blockset

MPC555 Motor Control Function Blockset



20 Mar 2006 (Updated )

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

mpc555_tpu_mask_creator_macrorewrite(macro_filename, macro_values)
function mpc555_tpu_mask_creator_macrorewrite(macro_filename, macro_values)

% Return if there are no values to be changed.
if isempty(macro_values)

% Open the macro file for which the parameters need to be changed
fid = fopen(macro_filename, 'r');
asifiledata = fread(fid, '*char')';

% Fixed parts of the regular expression used
expression_beginning = '\%macro[ \t]+';
expression_spaces = '[ \t]+';
expression_data = '''\$[A-F0-9]+''.';

% For each of the pairs of macros and values to be set
for current_macro = 1:size(macro_values,1)
    % This is the macro command name for which the value is to be replaced
    expression_command = macro_values{current_macro, 1};
    % This is the line which will replace the whole matching statement
    replacement_data =['%macro ', ...
        macro_values{current_macro, 1}, ...
        '          ''', macro_values{current_macro, 2}, '''.'];
    % This is the full REGEXP
    full_expression = [expression_beginning, expression_command, expression_spaces, expression_data];
    % Finally replace the data
    asifiledata = regexprep(asifiledata, full_expression, replacement_data);

% Write the modified file back to disk
fid = fopen(macro_filename, 'W');
fwrite(fid, asifiledata);


Contact us