• 晨旭晚霞
    了解作者
  • C/C++
    开发工具
  • 8KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 50
    下载次数
  • 2011-07-11 15:19
    上传日期
AVR单片机实现的485通讯从机接收程序(带帧校验)
AVR-RS485.zip
  • AVR RS485.doc
    45.5KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/622bb4a815da9b288bbdf861/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622bb4a815da9b288bbdf861/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">//<span class="ff2">&#20174;&#26426;&#31243;&#24207;</span></div><div class="t m0 x1 h3 y3 ff1 fs0 fc0 sc0 ls0 ws0">//01<span class="_ _0"> </span><span class="ff2">&#25968;&#25454;&#24103;</span></div><div class="t m0 x1 h3 y4 ff1 fs0 fc0 sc0 ls0 ws0">//02<span class="_ _0"> </span><span class="ff2">&#21629;&#20196;&#24103;</span></div><div class="t m0 x1 h3 y5 ff1 fs0 fc0 sc0 ls0 ws0">//03<span class="_ _0"> </span><span class="ff2">&#21151;&#33021;&#24103;</span> 01 <span class="ff2">&#30830;&#35748;</span> 02 <span class="ff2">&#21542;&#35748;</span></div><div class="t m0 x1 h4 y6 ff1 fs0 fc0 sc0 ls0 ws0">#include&lt;avr/io.h&gt;</div><div class="t m0 x1 h4 y7 ff1 fs0 fc0 sc0 ls0 ws0">#include&lt;avr/interrupt.h&gt;</div><div class="t m0 x1 h4 y8 ff1 fs0 fc0 sc0 ls0 ws0">#include&lt;inttypes.h&gt;</div><div class="t m0 x1 h4 y9 ff1 fs0 fc0 sc0 ls0 ws0">#include&lt;util/delay<span class="_ _1"></span>.h&gt;</div><div class="t m0 x1 h4 ya ff1 fs0 fc0 sc0 ls0 ws0">#include &lt;avr/pgmspace.h&gt;</div><div class="t m0 x1 h4 yb ff1 fs0 fc0 sc0 ls0 ws0">#include&lt;string.h&gt;</div><div class="t m0 x1 h3 yc ff1 fs0 fc0 sc0 ls0 ws0">#define myaddr 0x01 //<span class="ff2">&#23450;&#20041;&#26412;&#26426;&#22320;&#22336;</span></div><div class="t m0 x1 h3 yd ff1 fs0 fc0 sc0 ls0 ws0">#define rx_485(); asm("cbi 0x13,2"); //portd.2<span class="_ _0"> </span><span class="ff2">&#28165;&#38646;</span> <span class="ff2">&#25913;&#20026;&#25509;&#25910;&#29366;&#24577;</span></div><div class="t m0 x1 h3 ye ff1 fs0 fc0 sc0 ls0 ws0">#define tx_485(); asm("sbi 0x13,2"); //portd.2<span class="_ _0"> </span><span class="ff2">&#32622;&#20301;</span> <span class="ff2">&#25913;&#20026;&#21457;&#36865;&#29366;&#24577;</span></div><div class="t m0 x1 h4 yf ff1 fs0 fc0 sc0 ls0 ws0">volatile struct conn{</div><div class="t m0 x1 h4 y10 ff1 fs0 fc0 sc0 ls0 ws0">unsigned char buf[70];</div><div class="t m0 x1 h4 y11 ff1 fs0 fc0 sc0 ls0 ws0">unsigned char data[64];</div><div class="t m0 x1 h3 y12 ff1 fs0 fc0 sc0 ls0 ws0">unsigned char srcadd;//<span class="ff2">&#28304;&#22320;&#22336;</span></div><div class="t m0 x1 h3 y13 ff1 fs0 fc0 sc0 ls0 ws0">unsigned char aimadd;//<span class="ff2">&#30446;&#30340;&#22320;&#22336;</span></div><div class="t m0 x1 h3 y14 ff1 fs0 fc0 sc0 ls0 ws0">unsigned char tp;//<span class="ff2">&#24103;&#31867;&#22411;</span></div><div class="t m0 x1 h4 y15 ff1 fs0 fc0 sc0 ls0 ws0">int num;</div><div class="t m0 x1 h4 y16 ff1 fs0 fc0 sc0 ls0 ws0">int tmp;</div><div class="t m0 x1 h3 y17 ff1 fs0 fc0 sc0 ls0 ws0">unsigned char ver; //<span class="ff2">&#39564;&#35777;&#30721;</span>; </div><div class="t m0 x1 h3 y18 ff1 fs0 fc0 sc0 ls0 ws0">unsigned char err; //<span class="ff2">&#38169;&#35823;&#30721;</span>; 01:<span class="ff2">&#24103;&#26657;&#39564;&#38169;</span></div><div class="t m0 x1 h4 y19 ff1 fs0 fc0 sc0 ls0 ws0">}tx,rx;</div><div class="t m0 x1 h3 y1a ff1 fs0 fc0 sc0 ls0 ws0">volatile unsigned char com; //<span class="_ _2"></span><span class="ff2">&#21629;&#20196;</span></div><div class="t m0 x1 h4 y1b ff1 fs0 fc0 sc0 ls0 ws0">const unsigned char flash_str[] PROGMEM = "0123456789";</div><div class="t m0 x1 h4 y1c ff1 fs0 fc0 sc0 ls0 ws0">ISR(USAR<span class="_ _1"></span>T_RXC_vect)</div><div class="t m0 x1 h4 y1d ff1 fs0 fc0 sc0 ls0 ws0">{ </div><div class="t m0 x1 h4 y1e ff1 fs0 fc0 sc0 ls0 ws0"> rx.buf[rx.tmp]=UDR;</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐