<p><br></p><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">include</span></span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> u16;
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">char</span> u8;
<span class="hljs-meta">#<span class="hljs-meta-keyword">define</span> LED P2</span>
u16 i;
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">Tmier</span><span class="hljs-params">()</span>
</span>{
TMOD |=<span class="hljs-number">0X01</span>;
TH0=<span class="hljs-number">0XD8</span>;
TL0=<span class="hljs-number">0XF0</span>;
ET0=<span class="hljs-number">1</span>;
TR0=<span class="hljs-number">1</span>;
EA=<span class="hljs-number">1</span>;
}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">()</span>
</span>{
Tmier();
led=<span class="hljs-number">0xfe</span>;
<span class="hljs-keyword">while</span>(<span class="hljs-number">1</span>)
{
led=<span class="hljs-number">0xfe</span>;
IF(i==<span class="hljs-number">10</span>)
{
i=<span class="hljs-number">0</span>;
led=_cror_(led,<span class="hljs-number">1</span>);
}
}
}
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">Into</span> <span class="hljs-params">()</span> interrupt 1
</span>{
TH0=<span class="hljs-number">0XD8</span>;
TL0=<span class="hljs-number">0XF0</span>;
i++;
}</code></pre>
<font face="微软雅黑"><font style="font-size:18px">这样写为啥不行,而把led再定义之后就可以了呢?如在主函数中再加一句unsigned char data1=led;然后把后面的led换成data1流水灯就好了呢?为啥?</font></font><br>
<p><br></p>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
- #include<reg52.h>
- #include<intrins.h>
- typedef unsigned int u16;
- typedef unsigned char u8;
- #define LED P2
- u8 i;
- void Tmier()
- {
- TMOD |=0X01;
- TH0=0XD8;
- TL0=0XF0;
- ET0=1;
- TR0=1;
- EA=1;
- }
- void main()
- {
- Tmier();
- LED=0x7f;
- while(1)
- {
- // LED=0xfe;此句必须去掉
- if(i==10)
- {
- i=0;
- LED=_cror_(LED,1);
- }
- }
- }
- void Into () interrupt 1
- {
- TH0=0XD8;
- TL0=0XF0;
- i++;
- }
复制代码 最佳答案一周热门 更多>