51单片机智能小车想在循迹过程中利用串口通信传输数据,这样写测试起来好像并没有效果,为什么呢

2019-11-22 14:45发布

<p><br></p><pre style="max-width: 100%;"><code class="cpp hljs" codemark="1"><span class="hljs-comment">//串口通信初始化</span> <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">UART_init</span><span class="hljs-params">()</span> </span>{ TMOD = <span class="hljs-number">0x20</span>; SCON = <span class="hljs-number">0x50</span>; TH1 = <span class="hljs-number">0xFD</span>; TL1 = TH1; PCON = <span class="hljs-number">0x00</span>; EA = <span class="hljs-number">1</span>; ES = <span class="hljs-number">1</span>; TR1 = <span class="hljs-number">1</span>; PS = <span class="hljs-number">1</span>; PT1 = <span class="hljs-number">1</span>; } <span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">UART</span><span class="hljs-params">()</span> interrupt 4 </span>{ uchar receive_data; uchar i=<span class="hljs-number">500</span>; IF(RI) <span class="hljs-comment">//检测是否接收完成</span> { RI=<span class="hljs-number">0</span>; receive_data = SBUF; <span class="hljs-comment">//receive_data 取出接收缓存器的值</span> <span class="hljs-keyword">if</span>(receive_data==<span class="hljs-number">0x31</span>) { move_back(<span class="hljs-number">50</span>,<span class="hljs-number">50</span>); } } <span class="hljs-keyword">else</span> ti=<span class="hljs-number">0</span>; }</code></pre><p> 中断优先级已把串口和定时器1设高了,定时器0为输出pwm波,请问这样写有什么问题嘛</p><br> <br> <p><br></p>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。