<font face="微软雅黑"><font style="font-size:18px">我想用动态的数码管显示从200开始隔1s减1 但是使用的时候前面两个数码管数字是对的但是一直闪烁是为什么?</font></font><br>
<font face="微软雅黑"><font style="font-size:18px">程序如下:<br></font></font><pre style="max-width: 100%;"><code class="cpp hljs" codemark="1"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span></span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> uint unsigned int</span>
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> uchar unsigned char</span>
uchar temp,bai,shi,ge,aa;
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">display</span><span class="hljs-params">(uchar)</span></span>;
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">delay</span><span class="hljs-params">(uint)</span></span>;
uchar code tab1[]={<span class="hljs-number">0x3f</span>,<span class="hljs-number">0x06</span>,<span class="hljs-number">0x5b</span>,<span class="hljs-number">0x4f</span>,<span class="hljs-number">0x66</span>,<span class="hljs-number">0x6d</span>,<span class="hljs-number">0x7d</span>,<span class="hljs-number">0x07</span>,<span class="hljs-number">0x7f</span>,<span class="hljs-number">0x6f</span>};
sbit wela=P2^<span class="hljs-number">7</span>;
sbit dula=P2^<span class="hljs-number">6</span>;
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">yanshi</span><span class="hljs-params">()</span></span>;
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>
</span>{
temp=<span class="hljs-number">200</span>;
yanshi();
<span class="hljs-keyword">while</span>(<span class="hljs-number">1</span>)
{
IF(aa==<span class="hljs-number">20</span>)
{
aa=<span class="hljs-number">0</span>;
display(temp);
temp--;
}
}
}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">delay</span><span class="hljs-params">(uint z)</span>
</span>{
uint x,y;
<span class="hljs-keyword">for</span>(x=<span class="hljs-number">120</span>;x><span class="hljs-number">0</span>;x--)
<span class="hljs-keyword">for</span>(y=z;y><span class="hljs-number">0</span>;y--);
}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">name</span><span class="hljs-params">()</span>interrupt 1
</span>{
TH0=(<span class="hljs-number">65536</span><span class="hljs-number">-50000</span>)/<span class="hljs-number">256</span>;
TL0=(<span class="hljs-number">65536</span><span class="hljs-number">-50000</span>)%<span class="hljs-number">256</span>;
aa++;
}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">display</span><span class="hljs-params">(uchar temp)</span>
</span>{
bai=temp/<span class="hljs-number">100</span>;
shi=temp%<span class="hljs-number">100</span>/<span class="hljs-number">10</span>;
ge=temp%<span class="hljs-number">10</span>;
wela=<span class="hljs-number">1</span>;
P0=<span class="hljs-number">0xfe</span>;
wela=<span class="hljs-number">0</span>;
dula=<span class="hljs-number">1</span>;
P0=tab1[bai];
dula=<span class="hljs-number">0</span>;
delay(<span class="hljs-number">10</span>);
P0=<span class="hljs-number">0xff</span>;
wela=<span class="hljs-number">1</span>;
P0=<span class="hljs-number">0xfd</span>;
wela=<span class="hljs-number">0</span>;
dula=<span class="hljs-number">1</span>;
P0=tab1[shi];
dula=<span class="hljs-number">0</span>;
delay(<span class="hljs-number">10</span>);
P0=<span class="hljs-number">0xff</span>;
wela=<span class="hljs-number">1</span>;
P0=<span class="hljs-number">0xfb</span>;
wela=<span class="hljs-number">0</span>;
dula=<span class="hljs-number">1</span>;
P0=tab1[ge];
dula=<span class="hljs-number">0</span>;
delay(<span class="hljs-number">10</span>);
P0=<span class="hljs-number">0xff</span>;
}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">yanshi</span><span class="hljs-params">()</span>
</span>{
TMOD=<span class="hljs-number">0X01</span>;
TH0=(<span class="hljs-number">65536</span><span class="hljs-number">-50000</span>)/<span class="hljs-number">256</span>;
TL0=(<span class="hljs-number">65536</span><span class="hljs-number">-50000</span>)%<span class="hljs-number">256</span>;
IE=<span class="hljs-number">0x82</span>;
TR0=<span class="hljs-number">1</span>;
}</code></pre><font face="微软雅黑">
<br>
</font><br>
<br>
<ignore_js_op>
<dl class="tattl attm">
<dd>
<img src="data/attach/1911/7dxd9fy64rr1czoqnaio8xeub9rfd6c2.png" alt="QQ截图20190928004821.png" title="QQ截图20190928004821.png">
</dd>
</dl>
</ignore_js_op>
<p><br></p>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>