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

📄 regwrite.m

📁 这是一个关于MATLAB的函数
💻 M
字号:
function dummy = regwrite(cc,regname,value,represent,timeout)
%REGWRITE Writes a data value into the specified DSP register.
%   REGWRITE(CC, REGNAME, VALUE, REPRESENT, TIMEOUT) write the data 
%   from the VALUE parameter into in the specified register of the 
%   DSP processor.  The REGNAME parameter defines the destination 
%   register.  This operation is directed to the the processor 
%   referenced by the CC object.  The REPRESENT parameter specifies the 
%   interpretation of the register's data format.
%
%   REPRSENT - Representation of data in destination register
%   '2scomp' - (default) 2's complement signed integer
%   'binary' - Unsigned binary integer 
%   'ieee'   - IEEE floating point (32 and 64 bit registers, only)
%  
%   VALUE can be any scalar numeric value.   Note, the data type of the
%   this parameter does not effect the representation of the destination 
%   register. VALUE is automatically converted to the destination type, 
%   which in some cases may produce data loss.
%
%   TIMEOUT defines an upper limit (in seconds) on the time this method will wait
%   for completion of the write.  If this period is exceeded, this method will
%   immediately return with a timeout error.  In general, a timeout will not stop
%   the actual register write, but simply terminate waiting for a Code Composer 
%   response that indicates completion.  
%
%   REGWRITE(CC,REGNAME,VALUE,REPRESENT)  Same as above, except the timeout value 
%   defaults to the value provided by the CC object. Use CC.GET('timeout') 
%   to examine the default supplied by the object.
%
%   REGWRITE(CC,REGNAME,VALUE) Same as above, except the data type 
%   defaults to 'integer' and this routine writes VALUE as a signed 2's
%   complement data value
%
%   The supported values for REGNAME will depend on the DSP processr.  For 
%   example, the following registers are available on the TMS320C6xxx 
%   family of processors:
%   'A0' .. 'An' - Accumulator A registers
%   'B0' .. 'Bn' - Accumulator B registers
%   'PC','ISTP',IFR,'IER','IRP','NRP','AMR','CSR' - Other 32 bit registers
%   'A1:A0' .. 'B15:B14 ' - 64 bit Register pairs
%
%   Note, memory-mapped registers can only be modified with memory writes.
%   For the TMS320C5xxx family, this means the only register that is
%   available with the REGREAD method is the PC register.
%
%   See also REGREAD, WRITE, HEX2DEC.

%   Copyright 2001-2002 The MathWorks, Inc.
%   $Revision: 1.15 $ $Date: 2002/06/12 15:30:32 $

% Check input parameters
error(nargchk(2,5,nargin));
if ~ishandle(cc),
    error('First Parameter must be a CCSDSP Handle.');
end

% Parse timeout
if( nargin >= 5) & (~isempty(timeout)),
    if ~isnumeric(timeout) | length(timeout) ~= 1,
        error('TIMEOUT parameter must be a single numeric value.');
    end
    dtimeout = double(timeout);
else
    dtimeout = double(get(cc,'timeout'));
end
if( dtimeout < 0)
    error(['Negative TIMEOUT value "' num2str(dtimeout) '" not permitted.']);
end

if ischar(value) % hexadecimal input
    value = hex2dec(value); 
    represent = 'binary'; % raw value is being written
end

if cc.subfamily==84, % C54x Family    
	if nargin==3,       mmregwrite(cc,regname,value,'2scomp',cc.timeout);
	elseif nargin>=4,   mmregwrite(cc,regname,value,represent,dtimeout);
	end
else
	if nargin==3,       ccsmexswitchyard([26 cc.boardnum cc.procnum dtimeout cc.eventwaitms],regname,value);
	elseif nargin>=4,   ccsmexswitchyard([26 cc.boardnum cc.procnum dtimeout cc.eventwaitms],regname,value,represent);
	end

end

% [EOF] regwrite.m

⌨️ 快捷键说明

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