45) error (['Unable to read file "',filename,'" : invalid file type, or unsupported file version.']) end info.lExtItemHeaderLen = fread(fid,1,'*int32'); info.nChannels = fread(fid,1,'*int16'); % Number of channels info.nHorizAxisType = fread(fid,1,'*int16'); info.nCurChannel = fread(fid,1,'*int16'); info.dSampleTime = fread(fid,1,'*double'); % Number of milliseconds per sample info.dTimeOffset = fread(fid,1,'*double'); % Initial time offset in milliseconds info.dTimeScale = fread(fid,1,'*double'); % Time scale in milliseconds per division info.dTimeCursor1 = fread(fid,1,'*double'); info.dTimeCursor2 = fread(fid,1,'*double'); info.rcWindow = fread(fid,1,'*double'); info.nMeasurement = fread(fid,6,'*int16')'; info.fHilite = fread(fid,1,'*int16'); info.dFirstTimeOffset = fread(fid,1,'*double'); info.nRescale = fread(fid,1,'*int16'); info.szHorizUnits1 = deblank(fread(fid,40,'*char')'); % Horizontal units text info.szHorizUnits2 = deblank(fread(fid,10,'*char')'); % Horizontal units text (abbreviated) info.nInMemory = fread(fid,1,'*int16'); info.fGrid = fread(fid,1,'*int16'); info.fMarkers = fread(fid,1,'*int16'); info.nPlotDraft = fread(fid,1,'*int16'); info.nDispMode = fread(fid,1,'*int16'); info.nReserved = fread(fid,1,'*int16'); % Version 3.0 and above... if info.lVersion>=34 info.BShowToolBar = fread(fid,1,'*int16'); info.BShowChannelButtons = fread(fid,1,'*int16'); info.BShowMeasurements = fread(fid,1,'int16'); info.BShowMarkers = fread(fid,1,'*int16'); info.BShowJournal = fread(fid,1,'*int16'); info.CurXChannel = fread(fid,1,'*int16'); info.MmtPrecision = fread(fid,1,'*int16'); end % Version 3.02 and above... if info.lVersion>=35 info.NMeasurementRows = fread(fid,1,'*int16'); info.mmt = fread(fid,40,'*int16')'; info.mmtChan = fread(fid,40,'*int16')'; end % Version 3.5x and above... if info.lVersion>=36 info.MmtCalcOpnd1 = fread(fid,40,'*int16')'; info.MmtCalcOpnd2 = fread(fid,40,'*int16')'; info.MmtCalcOp = fread(fid,40,'*int16')'; info.MmtCalcConstant = fread(fid,40,'*double')'; end % Version and above... if info.lVersion>=38 tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.bNewGridwithMinor = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.colorMajorGrid = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.colorMinorGrid = fread(fid,1,'*int32'); info.wMajorGridStyle = fread(fid,1,'*int16'); info.wMinorGridStyle = fread(fid,1,'*int16'); info.wMajorGridWidth = fread(fid,1,'*int16'); info.wMinorGridWidth = fread(fid,1,'*int16'); info.bFixedUnitsDiv = fread(fid,1,'*int32'); info.bMid_Range_Show = fread(fid,1,'*int32'); info.dStart_Middle_Point = fread(fid,1,'*double'); info.dOffset_Point = fread(fid,60,'*double')'; info.hGrid = fread(fid,1,'*double'); info.vGrid = fread(fid,60,'*double')'; info.bEnableWaveTools = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=39 info.horizPrecision = fread(fid,1,'*int16'); end % Version and above... if info.lVersion>=41 fseek(fid,20,'cof') % RESERVED info.bOverlapMode = fread(fid,1,'*int32'); info.bShowHardware = fread(fid,1,'*int32'); info.bXAutoplot = fread(fid,1,'*int32'); info.bXAutoScroll = fread(fid,1,'*int32'); info.bStartButtonVisible = fread(fid,1,'*int32'); info.bCompressed = fread(fid,1,'*int32'); info.AlwaysStartButtonVisible = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=43 info.pathVideo = deblank(fread(fid,260,'*char')'); info.optSyncDelay = fread(fid,1,'*int32'); info.syncDelay = fread(fid,1,'*double'); info.bHRP_PasteMeasurements = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=45 info.graphType = fread(fid,1,'*int32')'; for n = 1:40 info.mmtCalcExpr{n} = deblank(fread(fid,256,'*char')'); end info.mmtMomentOrder = fread(fid,40,'*int32')'; info.mmtTimeDelay = fread(fid,40,'*int32')'; info.mmtEmbedDim = fread(fid,40,'*int32')'; info.mmtMIDelay = fread(fid,40,'*int32')'; end %% PER CHANNEL DATA SECTION for n = 1:info.nChannels info.lChanHeaderLen(n) = fread(fid,1,'*int32'); info.nNum(n) = fread(fid,1,'*int16'); info.szCommentText{n} = deblank(fread(fid,40,'*char')'); % Comment text tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.rgbColor{n} = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.nDispChan(n) = fread(fid,1,'*int16'); info.dVoltOffset(n) = fread(fid,1,'*double'); % Amplitude offset (volts) info.dVoltScale(n) = fread(fid,1,'*double'); % Amplitude scale (volts/div.) info.szUnitsText{n} = deblank(fread(fid,20,'*char')'); % Units text info.lBufLength(n) = fread(fid,1,'*int32'); % Number of data samples info.dAmplScale(n) = fread(fid,1,'*double'); % Units/count info.dAmplOffset(n) = fread(fid,1,'*double'); % Units info.nChanOrder(n) = fread(fid,1,'*int16'); info.nDispSize(n) = fread(fid,1,'*int16'); % Version 3.0 and above... if info.lVersion>=34 info.plotMode(n) = fread(fid,1,'*int16'); info.vMid(n) = fread(fid,1,'*double'); end % Version and above... if info.lVersion>=38 info.szDescription{n} = deblank(fread(fid,128,'*char')'); % String of channel description info.nVarSampleDivider(n) = fread(fid,1,'*int16'); % Channel divider of main frequency end % Version and above... if info.lVersion>=39 info.vertPrecision(n) = fread(fid,1,'*int16'); end % Version and above... if info.lVersion>=43 tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.ActiveSegmentColor{n} = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.ActiveSegmentStyle(n) = fread(fid,1,'*int32'); end end %% FOREIGN DATA SECTION info.nLength = fread(fid,1,'*int16'); info.nID = fread(fid,1,'*int16'); info.ByForeignData = fread(fid,double(info.nLength-4),'*int8')'; %% PER CHANNEL DATA TYPES SECTION for m = 1:info.nChannels info.nSize(m) = fread(fid,1,'*int16'); % Channel data size in bytes info.nType(m) = fread(fid,1,'*int16'); % Channel data type : 1 = double, and 2 = short (int16) end %% CHANNEL DATA SECTION % Raw data vector in interleaved format (indexed by bytes) rawData = fread(fid,double(info.lBufLength)*double(info.nSize'),'*int8'); % Channel sequence (indexed by bytes) cnt = 1; for m = 1:max(info.nVarSampleDivider) for n = 1:info.nChannels if mod(m-1,info.nVarSampleDivider(n))==0 channelSequence(cnt:(cnt+info.nSize(n)-1)) = int8(n); cnt = cnt + info.nSize(n); end end end % Raw data vector is padded with NaN's in order to have an integer number % of channel sequence repetitions tmp3 = numel(channelSequence) - rem(numel(rawData),numel(channelSequence)); if tmp3>0 rawData(end+1:end+tmp3) = NaN; end % Raw data vector is reshaped into a matrix (rows correspond to the channel % sequence, and columns correspond to each repetition of the sequence) rawData = reshape(rawData,numel(channelSequence),[]); % Raw data is extracted channel by channel, and converted into the % specified numeric type data = cell(1,info.nChannels); for n = 1:info.nChannels tmpChannel = rawData(channelSequence==n,:); if info.nType(n)==1; typ = 'double'; elseif info.nType(n)==2; typ = 'int16'; end data{n} = typecast(tmpChannel(:),typ); data{n}(info.lBufLength(n)+1:end) = []; end %% MARKERS HEADER SECTION info.lLength = fread(fid,1,'*int32'); info.lMarkers = fread(fid,1,'*int32'); % Number of markers %% MARKER ITEM SECTION if (info.lLength > 0) && (info.lMarkers > 0) for n = 1:info.lMarkers info.lSample(n) = fread(fid,1,'*int32'); % Location of marker info.fSelected(n) = fread(fid,1,'*int16'); info.fTextLocked(n) = fread(fid,1,'*int16'); info.fPositionLocked(n) = fread(fid,1,'*int16'); info.nTextLength(n) = fread(fid,1,'*int16'); % Length of marker text string info.szText{n} = deblank(fread(fid,double(info.nTextLength(n)+1),'*char')'); % Marker text string end else info.lSample = []; info.fSelected = []; info.fTextLocked = []; info.fPositionLocked = []; info.nTextLength = []; info.szText = []; end %% Closing file... fclose(fid); 簡介 ICE 的全名為 In Circuit Emulator,一般完整的 ICE 必須具備有下列的特徵: 1.能模擬 CPU 或單晶片微控器的動作 2.提供與 CPU 或微控器相同的輸出、輸入能力 3.提供記憶體模擬單晶片微控器的內部記憶體或模擬目標系統上的記憶體 (目標系統:Target System,為要開發的微電腦系統) 4.具有將匯流排信號儲存的能力 5.具有單步執行指令的能力 K&H"> 45) error (['Unable to read file "',filename,'" : invalid file type, or unsupported file version.']) end info.lExtItemHeaderLen = fread(fid,1,'*int32'); info.nChannels = fread(fid,1,'*int16'); % Number of channels info.nHorizAxisType = fread(fid,1,'*int16'); info.nCurChannel = fread(fid,1,'*int16'); info.dSampleTime = fread(fid,1,'*double'); % Number of milliseconds per sample info.dTimeOffset = fread(fid,1,'*double'); % Initial time offset in milliseconds info.dTimeScale = fread(fid,1,'*double'); % Time scale in milliseconds per division info.dTimeCursor1 = fread(fid,1,'*double'); info.dTimeCursor2 = fread(fid,1,'*double'); info.rcWindow = fread(fid,1,'*double'); info.nMeasurement = fread(fid,6,'*int16')'; info.fHilite = fread(fid,1,'*int16'); info.dFirstTimeOffset = fread(fid,1,'*double'); info.nRescale = fread(fid,1,'*int16'); info.szHorizUnits1 = deblank(fread(fid,40,'*char')'); % Horizontal units text info.szHorizUnits2 = deblank(fread(fid,10,'*char')'); % Horizontal units text (abbreviated) info.nInMemory = fread(fid,1,'*int16'); info.fGrid = fread(fid,1,'*int16'); info.fMarkers = fread(fid,1,'*int16'); info.nPlotDraft = fread(fid,1,'*int16'); info.nDispMode = fread(fid,1,'*int16'); info.nReserved = fread(fid,1,'*int16'); % Version 3.0 and above... if info.lVersion>=34 info.BShowToolBar = fread(fid,1,'*int16'); info.BShowChannelButtons = fread(fid,1,'*int16'); info.BShowMeasurements = fread(fid,1,'int16'); info.BShowMarkers = fread(fid,1,'*int16'); info.BShowJournal = fread(fid,1,'*int16'); info.CurXChannel = fread(fid,1,'*int16'); info.MmtPrecision = fread(fid,1,'*int16'); end % Version 3.02 and above... if info.lVersion>=35 info.NMeasurementRows = fread(fid,1,'*int16'); info.mmt = fread(fid,40,'*int16')'; info.mmtChan = fread(fid,40,'*int16')'; end % Version 3.5x and above... if info.lVersion>=36 info.MmtCalcOpnd1 = fread(fid,40,'*int16')'; info.MmtCalcOpnd2 = fread(fid,40,'*int16')'; info.MmtCalcOp = fread(fid,40,'*int16')'; info.MmtCalcConstant = fread(fid,40,'*double')'; end % Version and above... if info.lVersion>=38 tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.bNewGridwithMinor = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.colorMajorGrid = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.colorMinorGrid = fread(fid,1,'*int32'); info.wMajorGridStyle = fread(fid,1,'*int16'); info.wMinorGridStyle = fread(fid,1,'*int16'); info.wMajorGridWidth = fread(fid,1,'*int16'); info.wMinorGridWidth = fread(fid,1,'*int16'); info.bFixedUnitsDiv = fread(fid,1,'*int32'); info.bMid_Range_Show = fread(fid,1,'*int32'); info.dStart_Middle_Point = fread(fid,1,'*double'); info.dOffset_Point = fread(fid,60,'*double')'; info.hGrid = fread(fid,1,'*double'); info.vGrid = fread(fid,60,'*double')'; info.bEnableWaveTools = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=39 info.horizPrecision = fread(fid,1,'*int16'); end % Version and above... if info.lVersion>=41 fseek(fid,20,'cof') % RESERVED info.bOverlapMode = fread(fid,1,'*int32'); info.bShowHardware = fread(fid,1,'*int32'); info.bXAutoplot = fread(fid,1,'*int32'); info.bXAutoScroll = fread(fid,1,'*int32'); info.bStartButtonVisible = fread(fid,1,'*int32'); info.bCompressed = fread(fid,1,'*int32'); info.AlwaysStartButtonVisible = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=43 info.pathVideo = deblank(fread(fid,260,'*char')'); info.optSyncDelay = fread(fid,1,'*int32'); info.syncDelay = fread(fid,1,'*double'); info.bHRP_PasteMeasurements = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=45 info.graphType = fread(fid,1,'*int32')'; for n = 1:40 info.mmtCalcExpr{n} = deblank(fread(fid,256,'*char')'); end info.mmtMomentOrder = fread(fid,40,'*int32')'; info.mmtTimeDelay = fread(fid,40,'*int32')'; info.mmtEmbedDim = fread(fid,40,'*int32')'; info.mmtMIDelay = fread(fid,40,'*int32')'; end %% PER CHANNEL DATA SECTION for n = 1:info.nChannels info.lChanHeaderLen(n) = fread(fid,1,'*int32'); info.nNum(n) = fread(fid,1,'*int16'); info.szCommentText{n} = deblank(fread(fid,40,'*char')'); % Comment text tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.rgbColor{n} = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.nDispChan(n) = fread(fid,1,'*int16'); info.dVoltOffset(n) = fread(fid,1,'*double'); % Amplitude offset (volts) info.dVoltScale(n) = fread(fid,1,'*double'); % Amplitude scale (volts/div.) info.szUnitsText{n} = deblank(fread(fid,20,'*char')'); % Units text info.lBufLength(n) = fread(fid,1,'*int32'); % Number of data samples info.dAmplScale(n) = fread(fid,1,'*double'); % Units/count info.dAmplOffset(n) = fread(fid,1,'*double'); % Units info.nChanOrder(n) = fread(fid,1,'*int16'); info.nDispSize(n) = fread(fid,1,'*int16'); % Version 3.0 and above... if info.lVersion>=34 info.plotMode(n) = fread(fid,1,'*int16'); info.vMid(n) = fread(fid,1,'*double'); end % Version and above... if info.lVersion>=38 info.szDescription{n} = deblank(fread(fid,128,'*char')'); % String of channel description info.nVarSampleDivider(n) = fread(fid,1,'*int16'); % Channel divider of main frequency end % Version and above... if info.lVersion>=39 info.vertPrecision(n) = fread(fid,1,'*int16'); end % Version and above... if info.lVersion>=43 tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.ActiveSegmentColor{n} = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.ActiveSegmentStyle(n) = fread(fid,1,'*int32'); end end %% FOREIGN DATA SECTION info.nLength = fread(fid,1,'*int16'); info.nID = fread(fid,1,'*int16'); info.ByForeignData = fread(fid,double(info.nLength-4),'*int8')'; %% PER CHANNEL DATA TYPES SECTION for m = 1:info.nChannels info.nSize(m) = fread(fid,1,'*int16'); % Channel data size in bytes info.nType(m) = fread(fid,1,'*int16'); % Channel data type : 1 = double, and 2 = short (int16) end %% CHANNEL DATA SECTION % Raw data vector in interleaved format (indexed by bytes) rawData = fread(fid,double(info.lBufLength)*double(info.nSize'),'*int8'); % Channel sequence (indexed by bytes) cnt = 1; for m = 1:max(info.nVarSampleDivider) for n = 1:info.nChannels if mod(m-1,info.nVarSampleDivider(n))==0 channelSequence(cnt:(cnt+info.nSize(n)-1)) = int8(n); cnt = cnt + info.nSize(n); end end end % Raw data vector is padded with NaN's in order to have an integer number % of channel sequence repetitions tmp3 = numel(channelSequence) - rem(numel(rawData),numel(channelSequence)); if tmp3>0 rawData(end+1:end+tmp3) = NaN; end % Raw data vector is reshaped into a matrix (rows correspond to the channel % sequence, and columns correspond to each repetition of the sequence) rawData = reshape(rawData,numel(channelSequence),[]); % Raw data is extracted channel by channel, and converted into the % specified numeric type data = cell(1,info.nChannels); for n = 1:info.nChannels tmpChannel = rawData(channelSequence==n,:); if info.nType(n)==1; typ = 'double'; elseif info.nType(n)==2; typ = 'int16'; end data{n} = typecast(tmpChannel(:),typ); data{n}(info.lBufLength(n)+1:end) = []; end %% MARKERS HEADER SECTION info.lLength = fread(fid,1,'*int32'); info.lMarkers = fread(fid,1,'*int32'); % Number of markers %% MARKER ITEM SECTION if (info.lLength > 0) && (info.lMarkers > 0) for n = 1:info.lMarkers info.lSample(n) = fread(fid,1,'*int32'); % Location of marker info.fSelected(n) = fread(fid,1,'*int16'); info.fTextLocked(n) = fread(fid,1,'*int16'); info.fPositionLocked(n) = fread(fid,1,'*int16'); info.nTextLength(n) = fread(fid,1,'*int16'); % Length of marker text string info.szText{n} = deblank(fread(fid,double(info.nTextLength(n)+1),'*char')'); % Marker text string end else info.lSample = []; info.fSelected = []; info.fTextLocked = []; info.fPositionLocked = []; info.nTextLength = []; info.szText = []; end %% Closing file... fclose(fid); 簡介 ICE 的全名為 In Circuit Emulator,一般完整的 ICE 必須具備有下列的特徵: 1.能模擬 CPU 或單晶片微控器的動作 2.提供與 CPU 或微控器相同的輸出、輸入能力 3.提供記憶體模擬單晶片微控器的內部記憶體或模擬目標系統上的記憶體 (目標系統:Target System,為要開發的微電腦系統) 4.具有將匯流排信號儲存的能力 5.具有單步執行指令的能力 K&H">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

MTS-52 ICE K&H.

Similar presentations


Presentation on theme: "MTS-52 ICE K&H."— Presentation transcript:

1 MTS-52 ICE K&H

2 簡介 ICE 的全名為 In Circuit Emulator,一般完整的 ICE 必須具備有下列的特徵:
function [info, data] = acqread(filename) % ACQREAD Read a Biopac AcqKnowledge file. % [INFO, DATA] = ACQREAD(FILENAME) reads the content of the AcqKnowledge % file specified in the string FILENAME. INFO is a structure containing % the metadata (header, markers, etc.). DATA is a cell array, indexed % by the channel number, containing the acquired physiological signals. % % [INFO, DATA] = ACQREAD displays a dialog box that is used to retrieve % the desired file. % % ACQREAD supports all files created with Windows/PC versions of % AcqKnowledge (3.9.0 or below), BSL (3.7.0 or below), and BSL PRO % (3.7.0 or below). % % ACQREAD supports channels that were acquired using different sampling % rates, therefore having a different number of samples. % % Details of the AcqKnowledge file format are presented in Biopac's % Application Note #156 (last updated on February 23, 2007), and % available at : " % % ACQREAD, version 2.0 ( ) % Copyright (C) Sebastien Authier and Vincent Finnerty % % This program is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by % the Free Software Foundation; either version 2 of the License, or % (at your option) any later version. % % This program is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA % , USA %% Opening file... error(nargchk(0,1,nargin)) if nargin==1 if exist(filename,'file')~=2 error(['File "',filename,'" not found.']) else [fid,message] = fopen(filename,'r'); if fid==-1 error(message) end end else [filename,pathname] = uigetfile({'*.acq','AcqKnowledge File (*.acq)';... '*.*','All Files (*.*)'}); if filename==0 return else filename = fullfile(pathname,filename); [fid,message] = fopen(filename,'r'); if fid==-1 error(message) end end end %% GRAPH HEADER SECTION info.nItemHeaderLen = fread(fid,1,'*int16'); info.lVersion = fread(fid,1,'*int32'); % File version identifier % 30 = Pre-version 2.0 % 31 = Version 2.0 Beta 1 % 32 = Version 2.0 release % 33 = Version (Mac) % 34 = Version 3.0 In-house Release 1 % 35 = Version 3.03 % 36 = Version 3.5x (Win 95, 98, NT) % 37 = Version of BSL/PRO 3.6.x % 38 = Version of Acq (Win 98, 98SE, NT, Me, 2000) % 39 = Version of Acq or above (Win 98, 98SE, 2000, Me, XP) % 41 = Version of Acq or above (Win 98, 98SE, 2000, Me, XP) % 42 = Version of BSL/PRO 3.7.X or above (Win 98, 98SE, 2000, Me, XP) % 43 = Version of Acq or above (Win 98, 98SE, 2000, Me, XP) % 44 = Version of BSL/PRO 3.8.x or above % 45 = Version of Acq or above if (info.lVersion<30) || (info.lVersion>45) error (['Unable to read file "',filename,'" : invalid file type, or unsupported file version.']) end info.lExtItemHeaderLen = fread(fid,1,'*int32'); info.nChannels = fread(fid,1,'*int16'); % Number of channels info.nHorizAxisType = fread(fid,1,'*int16'); info.nCurChannel = fread(fid,1,'*int16'); info.dSampleTime = fread(fid,1,'*double'); % Number of milliseconds per sample info.dTimeOffset = fread(fid,1,'*double'); % Initial time offset in milliseconds info.dTimeScale = fread(fid,1,'*double'); % Time scale in milliseconds per division info.dTimeCursor1 = fread(fid,1,'*double'); info.dTimeCursor2 = fread(fid,1,'*double'); info.rcWindow = fread(fid,1,'*double'); info.nMeasurement = fread(fid,6,'*int16')'; info.fHilite = fread(fid,1,'*int16'); info.dFirstTimeOffset = fread(fid,1,'*double'); info.nRescale = fread(fid,1,'*int16'); info.szHorizUnits1 = deblank(fread(fid,40,'*char')'); % Horizontal units text info.szHorizUnits2 = deblank(fread(fid,10,'*char')'); % Horizontal units text (abbreviated) info.nInMemory = fread(fid,1,'*int16'); info.fGrid = fread(fid,1,'*int16'); info.fMarkers = fread(fid,1,'*int16'); info.nPlotDraft = fread(fid,1,'*int16'); info.nDispMode = fread(fid,1,'*int16'); info.nReserved = fread(fid,1,'*int16'); % Version 3.0 and above... if info.lVersion>=34 info.BShowToolBar = fread(fid,1,'*int16'); info.BShowChannelButtons = fread(fid,1,'*int16'); info.BShowMeasurements = fread(fid,1,'int16'); info.BShowMarkers = fread(fid,1,'*int16'); info.BShowJournal = fread(fid,1,'*int16'); info.CurXChannel = fread(fid,1,'*int16'); info.MmtPrecision = fread(fid,1,'*int16'); end % Version 3.02 and above... if info.lVersion>=35 info.NMeasurementRows = fread(fid,1,'*int16'); info.mmt = fread(fid,40,'*int16')'; info.mmtChan = fread(fid,40,'*int16')'; end % Version 3.5x and above... if info.lVersion>=36 info.MmtCalcOpnd1 = fread(fid,40,'*int16')'; info.MmtCalcOpnd2 = fread(fid,40,'*int16')'; info.MmtCalcOp = fread(fid,40,'*int16')'; info.MmtCalcConstant = fread(fid,40,'*double')'; end % Version and above... if info.lVersion>=38 tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.bNewGridwithMinor = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.colorMajorGrid = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.colorMinorGrid = fread(fid,1,'*int32'); info.wMajorGridStyle = fread(fid,1,'*int16'); info.wMinorGridStyle = fread(fid,1,'*int16'); info.wMajorGridWidth = fread(fid,1,'*int16'); info.wMinorGridWidth = fread(fid,1,'*int16'); info.bFixedUnitsDiv = fread(fid,1,'*int32'); info.bMid_Range_Show = fread(fid,1,'*int32'); info.dStart_Middle_Point = fread(fid,1,'*double'); info.dOffset_Point = fread(fid,60,'*double')'; info.hGrid = fread(fid,1,'*double'); info.vGrid = fread(fid,60,'*double')'; info.bEnableWaveTools = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=39 info.horizPrecision = fread(fid,1,'*int16'); end % Version and above... if info.lVersion>=41 fseek(fid,20,'cof') % RESERVED info.bOverlapMode = fread(fid,1,'*int32'); info.bShowHardware = fread(fid,1,'*int32'); info.bXAutoplot = fread(fid,1,'*int32'); info.bXAutoScroll = fread(fid,1,'*int32'); info.bStartButtonVisible = fread(fid,1,'*int32'); info.bCompressed = fread(fid,1,'*int32'); info.AlwaysStartButtonVisible = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=43 info.pathVideo = deblank(fread(fid,260,'*char')'); info.optSyncDelay = fread(fid,1,'*int32'); info.syncDelay = fread(fid,1,'*double'); info.bHRP_PasteMeasurements = fread(fid,1,'*int32'); end % Version and above... if info.lVersion>=45 info.graphType = fread(fid,1,'*int32')'; for n = 1:40 info.mmtCalcExpr{n} = deblank(fread(fid,256,'*char')'); end info.mmtMomentOrder = fread(fid,40,'*int32')'; info.mmtTimeDelay = fread(fid,40,'*int32')'; info.mmtEmbedDim = fread(fid,40,'*int32')'; info.mmtMIDelay = fread(fid,40,'*int32')'; end %% PER CHANNEL DATA SECTION for n = 1:info.nChannels info.lChanHeaderLen(n) = fread(fid,1,'*int32'); info.nNum(n) = fread(fid,1,'*int16'); info.szCommentText{n} = deblank(fread(fid,40,'*char')'); % Comment text tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.rgbColor{n} = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.nDispChan(n) = fread(fid,1,'*int16'); info.dVoltOffset(n) = fread(fid,1,'*double'); % Amplitude offset (volts) info.dVoltScale(n) = fread(fid,1,'*double'); % Amplitude scale (volts/div.) info.szUnitsText{n} = deblank(fread(fid,20,'*char')'); % Units text info.lBufLength(n) = fread(fid,1,'*int32'); % Number of data samples info.dAmplScale(n) = fread(fid,1,'*double'); % Units/count info.dAmplOffset(n) = fread(fid,1,'*double'); % Units info.nChanOrder(n) = fread(fid,1,'*int16'); info.nDispSize(n) = fread(fid,1,'*int16'); % Version 3.0 and above... if info.lVersion>=34 info.plotMode(n) = fread(fid,1,'*int16'); info.vMid(n) = fread(fid,1,'*double'); end % Version and above... if info.lVersion>=38 info.szDescription{n} = deblank(fread(fid,128,'*char')'); % String of channel description info.nVarSampleDivider(n) = fread(fid,1,'*int16'); % Channel divider of main frequency end % Version and above... if info.lVersion>=39 info.vertPrecision(n) = fread(fid,1,'*int16'); end % Version and above... if info.lVersion>=43 tmp = fread(fid,1,'*int32'); tmp = sprintf('%6s',dec2hex(tmp,6)); info.ActiveSegmentColor{n} = [hex2dec(tmp(5:6)) hex2dec(tmp(3:4)) hex2dec(tmp(1:2))]./255; info.ActiveSegmentStyle(n) = fread(fid,1,'*int32'); end end %% FOREIGN DATA SECTION info.nLength = fread(fid,1,'*int16'); info.nID = fread(fid,1,'*int16'); info.ByForeignData = fread(fid,double(info.nLength-4),'*int8')'; %% PER CHANNEL DATA TYPES SECTION for m = 1:info.nChannels info.nSize(m) = fread(fid,1,'*int16'); % Channel data size in bytes info.nType(m) = fread(fid,1,'*int16'); % Channel data type : 1 = double, and 2 = short (int16) end %% CHANNEL DATA SECTION % Raw data vector in interleaved format (indexed by bytes) rawData = fread(fid,double(info.lBufLength)*double(info.nSize'),'*int8'); % Channel sequence (indexed by bytes) cnt = 1; for m = 1:max(info.nVarSampleDivider) for n = 1:info.nChannels if mod(m-1,info.nVarSampleDivider(n))==0 channelSequence(cnt:(cnt+info.nSize(n)-1)) = int8(n); cnt = cnt + info.nSize(n); end end end % Raw data vector is padded with NaN's in order to have an integer number % of channel sequence repetitions tmp3 = numel(channelSequence) - rem(numel(rawData),numel(channelSequence)); if tmp3>0 rawData(end+1:end+tmp3) = NaN; end % Raw data vector is reshaped into a matrix (rows correspond to the channel % sequence, and columns correspond to each repetition of the sequence) rawData = reshape(rawData,numel(channelSequence),[]); % Raw data is extracted channel by channel, and converted into the % specified numeric type data = cell(1,info.nChannels); for n = 1:info.nChannels tmpChannel = rawData(channelSequence==n,:); if info.nType(n)==1; typ = 'double'; elseif info.nType(n)==2; typ = 'int16'; end data{n} = typecast(tmpChannel(:),typ); data{n}(info.lBufLength(n)+1:end) = []; end %% MARKERS HEADER SECTION info.lLength = fread(fid,1,'*int32'); info.lMarkers = fread(fid,1,'*int32'); % Number of markers %% MARKER ITEM SECTION if (info.lLength > 0) && (info.lMarkers > 0) for n = 1:info.lMarkers info.lSample(n) = fread(fid,1,'*int32'); % Location of marker info.fSelected(n) = fread(fid,1,'*int16'); info.fTextLocked(n) = fread(fid,1,'*int16'); info.fPositionLocked(n) = fread(fid,1,'*int16'); info.nTextLength(n) = fread(fid,1,'*int16'); % Length of marker text string info.szText{n} = deblank(fread(fid,double(info.nTextLength(n)+1),'*char')'); % Marker text string end else info.lSample = []; info.fSelected = []; info.fTextLocked = []; info.fPositionLocked = []; info.nTextLength = []; info.szText = []; end %% Closing file... fclose(fid); 簡介 ICE 的全名為 In Circuit Emulator,一般完整的 ICE 必須具備有下列的特徵: 1.能模擬 CPU 或單晶片微控器的動作 2.提供與 CPU 或微控器相同的輸出、輸入能力 3.提供記憶體模擬單晶片微控器的內部記憶體或模擬目標系統上的記憶體 (目標系統:Target System,為要開發的微電腦系統) 4.具有將匯流排信號儲存的能力 5.具有單步執行指令的能力 K&H

3 K&H

4 MTS-52 說明 MTS-52為針對 MCS-51 單晶片微控器所設計的簡易 ICE
雖然 MTS-52並非全功能的 ICE,不過也具備了大半 ICE 的功能,而且價格相當便宜,只要搭配上個人電腦即成一套簡易的 MCS-51 單晶片微控器的發展系統 (MCS-51 Development System) K&H

5 MTS-52與個人電腦的連接: Power Adaptor Serial Port MTS-52 Target Board K&H

6 MTS-51與MTS-52連接時的注意事項: 不必接電源線 Power adaptor Serial Port MTS-52
Target Board (MTS-51) K&H

7 編輯及組譯程式 Step 1 : 用文書編輯軟體編輯程式 利用文書編輯軟體編輯下列程式,編輯完畢將其存檔,並將檔名設為 TEST.ASM
MTS-52 讀取HEX檔時,若檔案中有相對應的SYM 檔存在,則 MTS-52反組譯時,會將其 label 顯示出來。若無 SYM 檔,則 label 無法顯示出來。 SYM 檔是在 link 的過程中產生,且在原始程式中必須加入假指令 .symbols on MTS-52 會使用到中斷向量,若使用者的程式佔用到這些空間,可能導致MTS-52 監控系統無法正常工作。因此建議將主程式的起始位置放在位址0050H 之後。 K&H

8 註: 所附 CD片內的程式TEST.ASM與本頁所示略有不同
.SYMBOLS ON ORG 0000H JMP MAIN ORG 0050H MAIN: MOV A,#80H LOOP: MOV P2,A RR A NOP CALL DELAY JMP LOOP DELAY: MOV R5,#FFH DELAY1: MOV R6,#FFH DELAY2: MOV R7,#05H DELAY3: DJNZ R7,DELAY3 DJNZ R6,DELAY2 DJNZ R5,DELAY1 RET 註: 所附 CD片內的程式TEST.ASM與本頁所示略有不同 K&H

9 Step 2:用組譯器 X8051 來組譯原始程式 Step 3:用連結器 LINK51
點選 TEST.ASM,並按住滑鼠左鍵,直接將檔案 TEST.ASM 拖曳至 X8051.EXE,然後放開滑鼠左鍵,則 X8051 自動執行,並完成組譯動作。組譯完會產生TEST.OBJ 檔案。 Step 3:用連結器 LINK51 雙擊 (double click) LINK51.EXE 鍵入 TEST [Enter] 鍵入 5 次 [Enter] 鍵入 c [Enter],完成連結工作,連結後會產生TEST.HEX, TEST.SYM K&H

10 MTS-52 操作簡介 程式編輯及組譯完畢後,即可使用 MTS-52 來進行程式的偵錯及執行 Step 1 : 進入 MTS-52
選擇 [開始]  [程式集]  [ 8051 ICE ]  [ 8051 ICE V2.09 ] K&H

11 K&H

12 Step 2 : MTS-52 與電腦連線 (connect)
1. 選擇 [Option]  [Connect] 使用ICE之前,必須先將 MTS-52 與電腦連線。 未連線前,所有的按鈕都是反白無法作用的。 連線後,系統才可以將 Hex 檔載入 MTS-52。 K&H

13 2. 選擇連線的 Serial Port 在 Serial Port 的選擇框內選取連線的 port number,然後按 [Connect] 按鈕。 K&H

14 What COM port number to specify
K&H

15 連線完成後: K&H

16 Step 3 : 載入 Hex 檔 選擇 [File]  [Open File] K&H

17 選擇要載入的 Hex 檔,然後按 [開啟舊檔] 按鈕。 ( 選擇 X8051\test.hex )
K&H

18 K&H

19 K&H

20 Step 4 : 執行程式 Go Step 5 : 停止執行 選擇 [Run]  [Go] 或按 [F9] 或點選 。
 接在 P2 上的 LED 亮點向右跑。 Step 5 : 停止執行 選擇 [Run]  [Pause] 或按 [Ctrl+F9] 或 點選 。  程式停止執行。 K&H

21 Step 6 : Reset ICE 選擇 [Run]  [Reset] 或點選 。 K&H

22 Step 7 : 設定中斷點 (break point)
Source Code 視窗的最左側,有類似「.」的紅點,代表著該指令可以設為中斷點。 將滑鼠移到紅點附近時,會游標會變成小手的標示,此時單擊滑鼠左鍵,即可將該行指令設為中斷點。 程式中最多能設 16 個中斷點。 K&H

23 K&H

24 Step 8 : 執行程式 Go 選擇 [Run]  [Go] 或按 [F9] 或點選 。  接執行到 RR A 指令時,停止執行。
K&H

25 Step 9 : 執行程式 Go 選擇 [Run]  [Go] 或按 [F9] 或點選 。 接執行到 RR A 指令時,停止執行。
K&H

26 Step 10 : Reset ICE 選擇 [Run]  [Reset] 或點選 。 K&H

27 Step 11 : 單步執行 Trace Into 選擇 [Run]  [Trace Into] 或按 [F7] 或點選 。 K&H

28 Step 12 : 單步執行 Trace Into 選擇 [Run]  [Trace Into] 或按 [F7] 或點選 。 K&H

29 Step 13 : 單步執行 2 次 K&H

30 Step 14 : 單步執行 Trace Into K&H

31 Step 15 : Reset ICE 選擇 [Run]  [Reset] 或點選 。 K&H

32 Step 16 : Reset ICE 選擇 [Run]  [Reset] 或點選 。 K&H

33 Step 17 : 單步執行 Step Over 選擇 [Run]  [錯成Trace Into] [改成Step Over]或按 [F8] 或點選 。 K&H

34 Step 18 : 單步執行 3 次 K&H

35 Step 19 : 單步執行 Step Over 選擇 [Run]  [錯成Trace Into] [改成Step Over]或按 [F8] 或點選 。 K&H

36 Step 20 : 修改程式、重新組譯及連結 Step 21 :載入 Hex 檔 用文書編輯開啟程式,然後進行修改
將 RR A 修改為 RL A 修改完畢後存檔 用組譯器 X8051 來組譯原始程式 用連結器 LINK51,連結後會產生TEST.HEX, TEST.SYM Step 21 :載入 Hex 檔 選擇 [File]  [Open File] 選擇要載入的 Hex 檔,然後按 [開啟舊檔] 按鈕。( 選擇 X8051\test.hex ) K&H

37 Step 22 : 執行程式 Go Step 23 : 停止執行 Step 24 : 結束 MTS-52
選擇 [Run]  [Go] 或按 [F9] 或點選 。  接在 P2 上的 LED 亮點向左跑。 Step 23 : 停止執行 選擇 [Run]  [Pause] 或按 [Ctrl+F9] 或 點選 。 程式停止執行。 Step 24 : 結束 MTS-52 選擇 [File]  [Exit] K&H

38 MTS-52 功能表介紹 1 [File] 功能 1). [Open File] : 開啟檔案 2). [Save File] : 儲存檔案
3). [Save As] : 另存新檔 4). [Exit] : 離開 K&H

39 2. [View] 功能 1). [Output Message]:顯示 Output Message 視窗
2). [Register Inspector]:顯示 Register Inspector 視窗 3). [Internal Memory Inspector]: 顯示 Internal Memory Inspector 視窗 4). [Code Inspector]:顯示 Code Inspector 視窗 K&H

40 從目前的程式計數器所指到的指令開始執行,一直到設為中斷點的指令或點選 [Pause] 為止。設為中斷點的指令會被執行完畢後才停止執行。
3. [Run] 功能: 1). [Go] 或按 [F9]: 從目前的程式計數器所指到的指令開始執行,一直到設為中斷點的指令或點選 [Pause] 為止。設為中斷點的指令會被執行完畢後才停止執行。 K&H

41 建議將主程式的起始位置放在位址 0050H 之後,換句話說,建議將程式開頭寫成以下的形式: ORG 0000H
[注意事項] 程式的起始位置 建議將主程式的起始位置放在位址 0050H 之後,換句話說,建議將程式開頭寫成以下的形式: ORG 0000H JMP MAIN ORG 0050H MAIN: MTS-52 會使用到某一特殊中斷向量(33H),若使用者的程式佔用到此一空間,可能導致 MTS-52 監控系統無法正常工作。因此建議將主程式的起始位置放在位址 0050H 之後。 此一特殊中斷向量的位址與標準 MCS-51 的中斷向量不重疊,所以標準 MCS-51 的中斷向量仍可正常使用。 K&H

42 P3.6 及 P3.7 為外部記憶體的讀取與寫入,若將其設成 0 會導致監控程式無法正常工作,應該避免修改。
[注意事項] MTS-52 會使用到某一特殊中斷向量(33H),因此使用者程式若將 EA (中斷致能旗標) 設為 0,可能導致 MTS-52 監控系統無法 PAUSE 使用者程式。 I/O Port 3.6 與 Port 3.7 P3.6 及 P3.7 為外部記憶體的讀取與寫入,若將其設成 0 會導致監控程式無法正常工作,應該避免修改。 Stack Point 後的 5 個 bytes 為系統監控所佔用,修改該處的記憶體空間將不會有任何作用。 建議:Stack 使用 20H 以後的記憶空間,較不容易因為 bank 的切換造成資料的遺失或錯誤。 K&H

43 重置 (reset) MTS-52。一些特殊暫存器會被設為重置後的預設值 (default value)。
2). [Pause] 或按 [Ctrl+F9]: 停止程式的執行,並回 MTS-52 監控程式。 3). [Reset]: 重置 (reset) MTS-52。一些特殊暫存器會被設為重置後的預設值 (default value)。 4). [Trace Into] 或按 [F7] : 單步執行,MTS-52 會執行程式計數器所指到的指令,執行一個指令後即停止執行。 5). [Step over] 或按 [F8]: 單步執行。程式計數器所指到的指令若為 Cal l指令,則執行完副程式之後才停止;若為其它指令,則執行程式計數器所指到的指令後,即停止執行。 K&H

44 6). [Toggle Breakpoint]: 中斷點設定切換。
也可用直接點選在 Source Code 視窗的最左側的紅點方式來切換中斷點。 7). [Breakpoint Edit]: 中斷點通過次數 (pass count) 編輯。 也可用將游標移至中斷點,然後按滑鼠右鍵的方式來編輯中斷點通過次數 。 K&H

45 按 [Edit] 按鈕。 K&H

46 輸入通過次數 (例如 : 20 )。 按 [OK] 按鈕。 K&H

47 按 [OK] 按鈕完成設定。 K&H

48 1). [Display Internal Data Memory (DI)]: 顯示內部資料記憶體。
2). [Display Register (DR)]: 顯示暫存器。 K&H

49 3). [Modify Register (MR)] : 修改暫存器。
也可用雙擊 (double click) Register Inspector視窗中的暫存器數值方式修改。 資料輸入格式: 0Xbb , bb : 十六進位數值 K&H

50 4). [Modify Internal Data Memory (MI)] : 修改內部資料記憶體。
也可用雙擊 (double click) Internal Data Memory 視窗中的記憶體數值方式修改。 資料輸入格式: 0Xbb , bb : 十六進位數值 K&H

51 在 Output Message 視窗顯示連線的詳細資料
5. [Option] 功能: 1). [Connect]:連接 MTS-52 2). [Disconnect]:中止 MTS-52 連線 3). [Show Event]: 在 Output Message 視窗顯示連線的詳細資料 K&H

52 6. [Window] 功能: 1). [Cascade]: K&H

53 2). [Tile]: K&H

54 K&H


Download ppt "MTS-52 ICE K&H."

Similar presentations


Ads by Google