<p>
如附图</p><p>
想用定时器来定时产生中断的方式做流水灯。</p><p>
程序跑起来后,可以产生10次中断,10次过后,程序停在SJMP $,这个位置。</p><p>
请大神帮指出是什么原因</p><pre style="max-width: 100%;"><code class="cpp hljs" codemark="1">ORG <span class="hljs-number">0000</span>H
LJMP AA
ORG <span class="hljs-number">000</span>BH <span class="hljs-comment">//定时器T0中断入口</span>
AJMP IT0P <span class="hljs-comment">//转中断处理程序</span>
AA:CLR A <span class="hljs-comment">//累加器A清零</span>
MOV A,<span class="hljs-meta">#11111110B <span class="hljs-comment">//累加器A赋初值 </span></span>
tiME:MOV TMOD,<span class="hljs-meta">#01H <span class="hljs-comment">//设定工作模式,T0为16位定时器</span></span>
CLR TF0 <span class="hljs-comment">// 定时器溢出标志清零</span>
SETB TR0 <span class="hljs-comment">//允许开启定时器</span>
SETB ET0 <span class="hljs-comment">// 中断允许寄存器IE中,设定允许定时器T0中断</span>
SETB PT0 <span class="hljs-comment">//将定时器T0中断设定为最高优先级</span>
SETB EA <span class="hljs-comment">//总中断允许</span>
Initial:MOV R7,<span class="hljs-meta">#0AH <span class="hljs-comment">//R7作为计数器,装入初值</span></span>
MOV TH0,<span class="hljs-meta">#00H <span class="hljs-comment">//装入定时器高8位</span></span>
MOV TL0,<span class="hljs-meta">#00H <span class="hljs-comment">//装入定时器低8位</span></span>
SJMP [ DISCUZ_CODE_1 ]nbsp;
IT0P: DJNZ R7,RE <span class="hljs-comment">//若计数器减1不为0,则中断时间不够,中断返回</span>
RL A <span class="hljs-comment">//</span>
MOV P0,A <span class="hljs-comment">// 设定P0口</span>
SJMP TIME
RE: RETI </code></pre><p><span style="background-color: rgb(248, 248, 248); color: rgb(51, 51, 51); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; white-space: pre-wrap;">END </span> </p><br>
<ignore_js_op>
<dl class="tattl attm">
<dd>
<img src="data/attach/1911/uz6ccdgcjap5ogvk237gcm4t4pts1sen.png" alt="捕获.PNG" title="捕获.PNG">
</dd>
</dl>
</ignore_js_op>
<p><br></p>
一周热门 更多>