JTAG边界扫描电路又称为Boundary Sean Test(BST),一般采用4线接口(5线接口中有一个接口为主复位信号),也可以通过PC的RS232接口就能模拟BST的功能。典型的边界扫描结构如下图:
![](/assets/blank.gif)
IEEE标准所规定BST结构为:当器件工作在JTAG的BST模式时,使用4个专用I/O引脚和一个可选引脚TRST作为JTAG引脚,这4个专用引脚为TDI、TDO、TMS、TCK。
所有基于JTAG的操作都必须同步于JTAG时钟信号TCK,在TCK的上升沿读取或输出有效数据,有严格的建立、保持时间要求,并且JTAG电路追求稳定性,因此一般情况下时钟不会太高。时序图参考下图:
![](/assets/blank.gif)
JTAG扫描电路的工作流程为:TMS、TRST 和TCK引脚管理TAP控制器的操作,TDI和TDO为数据寄存器提供串行通道。TDI也为指令寄存器提供数据,然后为数据寄存器产生控制逻辑。对于选择寄存器、装载数据、检测和将结果移出的控制信号,由测试时钟(TCK)和测试模式(TMS)选择两个控制信号决定。在四线接口标准中,利用TDI,TDO,TCK,TMS四个信号,它们合成为TAP测试处理端口(Test Access Port),测试复位信号(TRST,一般以低电平有效)一般作为可选的第五个端口信号。去网上搬一张流程图:
![](/assets/blank.gif)
#mermaid-svg-pY50jbY0llC0sWYM .label{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);fill:#333;color:#333}#mermaid-svg-pY50jbY0llC0sWYM .label text{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .node rect,#mermaid-svg-pY50jbY0llC0sWYM .node circle,#mermaid-svg-pY50jbY0llC0sWYM .node ellipse,#mermaid-svg-pY50jbY0llC0sWYM .node polygon,#mermaid-svg-pY50jbY0llC0sWYM .node path{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-pY50jbY0llC0sWYM .node .label{text-align:center;fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .node.clickable{cursor:pointer}#mermaid-svg-pY50jbY0llC0sWYM .arrowheadPath{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .edgePath .path{stroke:#333;stroke-width:1.5px}#mermaid-svg-pY50jbY0llC0sWYM .flowchart-link{stroke:#333;fill:none}#mermaid-svg-pY50jbY0llC0sWYM .edgeLabel{background-color:#e8e8e8;text-align:center}#mermaid-svg-pY50jbY0llC0sWYM .edgeLabel rect{opacity:0.9}#mermaid-svg-pY50jbY0llC0sWYM .edgeLabel span{color:#333}#mermaid-svg-pY50jbY0llC0sWYM .cluster rect{fill:#ffffde;stroke:#aa3;stroke-width:1px}#mermaid-svg-pY50jbY0llC0sWYM .cluster text{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:12px;background:#ffffde;border:1px solid #aa3;border-radius:2px;pointer-events:none;z-index:100}#mermaid-svg-pY50jbY0llC0sWYM .actor{stroke:#ccf;fill:#ECECFF}#mermaid-svg-pY50jbY0llC0sWYM text.actor>tspan{fill:#000;stroke:none}#mermaid-svg-pY50jbY0llC0sWYM .actor-line{stroke:grey}#mermaid-svg-pY50jbY0llC0sWYM .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333}#mermaid-svg-pY50jbY0llC0sWYM .messageLine1{stroke-width:1.5;stroke-dasharray:2, 2;stroke:#333}#mermaid-svg-pY50jbY0llC0sWYM #arrowhead path{fill:#333;stroke:#333}#mermaid-svg-pY50jbY0llC0sWYM .sequenceNumber{fill:#fff}#mermaid-svg-pY50jbY0llC0sWYM #sequencenumber{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM #crosshead path{fill:#333;stroke:#333}#mermaid-svg-pY50jbY0llC0sWYM .messageText{fill:#333;stroke:#333}#mermaid-svg-pY50jbY0llC0sWYM .labelBox{stroke:#ccf;fill:#ECECFF}#mermaid-svg-pY50jbY0llC0sWYM .labelText,#mermaid-svg-pY50jbY0llC0sWYM .labelText>tspan{fill:#000;stroke:none}#mermaid-svg-pY50jbY0llC0sWYM .loopText,#mermaid-svg-pY50jbY0llC0sWYM .loopText>tspan{fill:#000;stroke:none}#mermaid-svg-pY50jbY0llC0sWYM .loopLine{stroke-width:2px;stroke-dasharray:2, 2;stroke:#ccf;fill:#ccf}#mermaid-svg-pY50jbY0llC0sWYM .note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-pY50jbY0llC0sWYM .noteText,#mermaid-svg-pY50jbY0llC0sWYM .noteText>tspan{fill:#000;stroke:none}#mermaid-svg-pY50jbY0llC0sWYM .activation0{fill:#f4f4f4;stroke:#666}#mermaid-svg-pY50jbY0llC0sWYM .activation1{fill:#f4f4f4;stroke:#666}#mermaid-svg-pY50jbY0llC0sWYM .activation2{fill:#f4f4f4;stroke:#666}#mermaid-svg-pY50jbY0llC0sWYM .mermaid-main-font{font-family:"trebuchet ms", verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM .section{stroke:none;opacity:0.2}#mermaid-svg-pY50jbY0llC0sWYM .section0{fill:rgba(102,102,255,0.49)}#mermaid-svg-pY50jbY0llC0sWYM .section2{fill:#fff400}#mermaid-svg-pY50jbY0llC0sWYM .section1,#mermaid-svg-pY50jbY0llC0sWYM .section3{fill:#fff;opacity:0.2}#mermaid-svg-pY50jbY0llC0sWYM .sectionTitle0{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .sectionTitle1{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .sectionTitle2{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .sectionTitle3{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .sectionTitle{text-anchor:start;font-size:11px;text-height:14px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM .grid .tick{stroke:#d3d3d3;opacity:0.8;shape-rendering:crispEdges}#mermaid-svg-pY50jbY0llC0sWYM .grid .tick text{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM .grid path{stroke-width:0}#mermaid-svg-pY50jbY0llC0sWYM .today{fill:none;stroke:red;stroke-width:2px}#mermaid-svg-pY50jbY0llC0sWYM .task{stroke-width:2}#mermaid-svg-pY50jbY0llC0sWYM .taskText{text-anchor:middle;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM .taskText:not([font-size]){font-size:11px}#mermaid-svg-pY50jbY0llC0sWYM .taskTextOutsideRight{fill:#000;text-anchor:start;font-size:11px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM .taskTextOutsideLeft{fill:#000;text-anchor:end;font-size:11px}#mermaid-svg-pY50jbY0llC0sWYM .task.clickable{cursor:pointer}#mermaid-svg-pY50jbY0llC0sWYM .taskText.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-pY50jbY0llC0sWYM .taskTextOutsideLeft.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-pY50jbY0llC0sWYM .taskTextOutsideRight.clickable{cursor:pointer;fill:#003163 !important;font-weight:bold}#mermaid-svg-pY50jbY0llC0sWYM .taskText0,#mermaid-svg-pY50jbY0llC0sWYM .taskText1,#mermaid-svg-pY50jbY0llC0sWYM .taskText2,#mermaid-svg-pY50jbY0llC0sWYM .taskText3{fill:#fff}#mermaid-svg-pY50jbY0llC0sWYM .task0,#mermaid-svg-pY50jbY0llC0sWYM .task1,#mermaid-svg-pY50jbY0llC0sWYM .task2,#mermaid-svg-pY50jbY0llC0sWYM .task3{fill:#8a90dd;stroke:#534fbc}#mermaid-svg-pY50jbY0llC0sWYM .taskTextOutside0,#mermaid-svg-pY50jbY0llC0sWYM .taskTextOutside2{fill:#000}#mermaid-svg-pY50jbY0llC0sWYM .taskTextOutside1,#mermaid-svg-pY50jbY0llC0sWYM .taskTextOutside3{fill:#000}#mermaid-svg-pY50jbY0llC0sWYM .active0,#mermaid-svg-pY50jbY0llC0sWYM .active1,#mermaid-svg-pY50jbY0llC0sWYM .active2,#mermaid-svg-pY50jbY0llC0sWYM .active3{fill:#bfc7ff;stroke:#534fbc}#mermaid-svg-pY50jbY0llC0sWYM .activeText0,#mermaid-svg-pY50jbY0llC0sWYM .activeText1,#mermaid-svg-pY50jbY0llC0sWYM .activeText2,#mermaid-svg-pY50jbY0llC0sWYM .activeText3{fill:#000 !important}#mermaid-svg-pY50jbY0llC0sWYM .done0,#mermaid-svg-pY50jbY0llC0sWYM .done1,#mermaid-svg-pY50jbY0llC0sWYM .done2,#mermaid-svg-pY50jbY0llC0sWYM .done3{stroke:grey;fill:#d3d3d3;stroke-width:2}#mermaid-svg-pY50jbY0llC0sWYM .doneText0,#mermaid-svg-pY50jbY0llC0sWYM .doneText1,#mermaid-svg-pY50jbY0llC0sWYM .doneText2,#mermaid-svg-pY50jbY0llC0sWYM .doneText3{fill:#000 !important}#mermaid-svg-pY50jbY0llC0sWYM .crit0,#mermaid-svg-pY50jbY0llC0sWYM .crit1,#mermaid-svg-pY50jbY0llC0sWYM .crit2,#mermaid-svg-pY50jbY0llC0sWYM .crit3{stroke:#f88;fill:red;stroke-width:2}#mermaid-svg-pY50jbY0llC0sWYM .activeCrit0,#mermaid-svg-pY50jbY0llC0sWYM .activeCrit1,#mermaid-svg-pY50jbY0llC0sWYM .activeCrit2,#mermaid-svg-pY50jbY0llC0sWYM .activeCrit3{stroke:#f88;fill:#bfc7ff;stroke-width:2}#mermaid-svg-pY50jbY0llC0sWYM .doneCrit0,#mermaid-svg-pY50jbY0llC0sWYM .doneCrit1,#mermaid-svg-pY50jbY0llC0sWYM .doneCrit2,#mermaid-svg-pY50jbY0llC0sWYM .doneCrit3{stroke:#f88;fill:#d3d3d3;stroke-width:2;cursor:pointer;shape-rendering:crispEdges}#mermaid-svg-pY50jbY0llC0sWYM .milestone{transform:rotate(45deg) scale(0.8, 0.8)}#mermaid-svg-pY50jbY0llC0sWYM .milestoneText{font-style:italic}#mermaid-svg-pY50jbY0llC0sWYM .doneCritText0,#mermaid-svg-pY50jbY0llC0sWYM .doneCritText1,#mermaid-svg-pY50jbY0llC0sWYM .doneCritText2,#mermaid-svg-pY50jbY0llC0sWYM .doneCritText3{fill:#000 !important}#mermaid-svg-pY50jbY0llC0sWYM .activeCritText0,#mermaid-svg-pY50jbY0llC0sWYM .activeCritText1,#mermaid-svg-pY50jbY0llC0sWYM .activeCritText2,#mermaid-svg-pY50jbY0llC0sWYM .activeCritText3{fill:#000 !important}#mermaid-svg-pY50jbY0llC0sWYM .titleText{text-anchor:middle;font-size:18px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM g.classGroup text{fill:#9370db;stroke:none;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family);font-size:10px}#mermaid-svg-pY50jbY0llC0sWYM g.classGroup text .title{font-weight:bolder}#mermaid-svg-pY50jbY0llC0sWYM g.clickable{cursor:pointer}#mermaid-svg-pY50jbY0llC0sWYM g.classGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-pY50jbY0llC0sWYM g.classGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM .classLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.5}#mermaid-svg-pY50jbY0llC0sWYM .classLabel .label{fill:#9370db;font-size:10px}#mermaid-svg-pY50jbY0llC0sWYM .relation{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-pY50jbY0llC0sWYM .dashed-line{stroke-dasharray:3}#mermaid-svg-pY50jbY0llC0sWYM #compositionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM #compositionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM #aggregationStart{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM #aggregationEnd{fill:#ECECFF;stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM #dependencyStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM #dependencyEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM #extensionStart{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM #extensionEnd{fill:#9370db;stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM .commit-id,#mermaid-svg-pY50jbY0llC0sWYM .commit-msg,#mermaid-svg-pY50jbY0llC0sWYM .branch-label{fill:lightgrey;color:lightgrey;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM .pieTitleText{text-anchor:middle;font-size:25px;fill:#000;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM .slice{font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM g.stateGroup text{fill:#9370db;stroke:none;font-size:10px;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM g.stateGroup text{fill:#9370db;fill:#333;stroke:none;font-size:10px}#mermaid-svg-pY50jbY0llC0sWYM g.statediagram-cluster .cluster-label text{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM g.stateGroup .state-title{font-weight:bolder;fill:#000}#mermaid-svg-pY50jbY0llC0sWYM g.stateGroup rect{fill:#ECECFF;stroke:#9370db}#mermaid-svg-pY50jbY0llC0sWYM g.stateGroup line{stroke:#9370db;stroke-width:1}#mermaid-svg-pY50jbY0llC0sWYM .transition{stroke:#9370db;stroke-width:1;fill:none}#mermaid-svg-pY50jbY0llC0sWYM .stateGroup .composit{fill:white;border-bottom:1px}#mermaid-svg-pY50jbY0llC0sWYM .stateGroup .alt-composit{fill:#e0e0e0;border-bottom:1px}#mermaid-svg-pY50jbY0llC0sWYM .state-note{stroke:#aa3;fill:#fff5ad}#mermaid-svg-pY50jbY0llC0sWYM .state-note text{fill:black;stroke:none;font-size:10px}#mermaid-svg-pY50jbY0llC0sWYM .stateLabel .box{stroke:none;stroke-width:0;fill:#ECECFF;opacity:0.7}#mermaid-svg-pY50jbY0llC0sWYM .edgeLabel text{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .stateLabel text{fill:#000;font-size:10px;font-weight:bold;font-family:'trebuchet ms', verdana, arial;font-family:var(--mermaid-font-family)}#mermaid-svg-pY50jbY0llC0sWYM .node circle.state-start{fill:black;stroke:black}#mermaid-svg-pY50jbY0llC0sWYM .node circle.state-end{fill:black;stroke:white;stroke-width:1.5}#mermaid-svg-pY50jbY0llC0sWYM #statediagram-barbEnd{fill:#9370db}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-cluster rect{fill:#ECECFF;stroke:#9370db;stroke-width:1px}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-cluster rect.outer{rx:5px;ry:5px}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-state .divider{stroke:#9370db}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-state .title-state{rx:5px;ry:5px}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-cluster.statediagram-cluster .inner{fill:white}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-cluster.statediagram-cluster-alt .inner{fill:#e0e0e0}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-cluster .inner{rx:0;ry:0}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-state rect.basic{rx:5px;ry:5px}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-state rect.divider{stroke-dasharray:10,10;fill:#efefef}#mermaid-svg-pY50jbY0llC0sWYM .note-edge{stroke-dasharray:5}#mermaid-svg-pY50jbY0llC0sWYM .statediagram-note rect{fill:#fff5ad;stroke:#aa3;stroke-width:1px;rx:0;ry:0}:root{--mermaid-font-family: '"trebuchet ms", verdana, arial';--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive}#mermaid-svg-pY50jbY0llC0sWYM .error-icon{fill:#522}#mermaid-svg-pY50jbY0llC0sWYM .error-text{fill:#522;stroke:#522}#mermaid-svg-pY50jbY0llC0sWYM .edge-thickness-normal{stroke-width:2px}#mermaid-svg-pY50jbY0llC0sWYM .edge-thickness-thick{stroke-width:3.5px}#mermaid-svg-pY50jbY0llC0sWYM .edge-pattern-solid{stroke-dasharray:0}#mermaid-svg-pY50jbY0llC0sWYM .edge-pattern-dashed{stroke-dasharray:3}#mermaid-svg-pY50jbY0llC0sWYM .edge-pattern-dotted{stroke-dasharray:2}#mermaid-svg-pY50jbY0llC0sWYM .marker{fill:#333}#mermaid-svg-pY50jbY0llC0sWYM .marker.cross{stroke:#333}:root { --mermaid-font-family: "trebuchet ms", verdana, arial;}#mermaid-svg-pY50jbY0llC0sWYM {color: rgba(0, 0, 0, 0.75);font: ;}
SCLK
MOSI
MISO
SCE
主机设备
从机设备