MSP430串口通信

  • q8_504859
    了解作者
  • 3.7KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-28 11:34
    上传日期
通过MSP430单片机发送数据,进行串口通信
MSP430串口通信.zip
  • MSP430串口通信.doc
    20KB
内容介绍
<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://csdnimg.cn/release/download_crawler_static/css/base.min.css"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/css/fancy.min.css"><link rel="stylesheet" href="https://csdnimg.cn/release/download_crawler_static/8555533/raw.css"><script src="https://csdnimg.cn/release/download_crawler_static/js/compatibility.min.js"></script><script src="https://csdnimg.cn/release/download_crawler_static/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://csdnimg.cn/release/download_crawler_static/8555533/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">msp430g2553<span class="_ _0"> </span><span class="ff2">&#19982;&#20018;&#21475;&#36890;&#20449;&#30340;&#39537;&#21160;&#31243;&#24207;</span></div><div class="t m0 x1 h4 y3 ff1 fs0 fc0 sc0 ls0 ws0">#include "uart.h"</div><div class="t m0 x1 h4 y4 ff1 fs0 fc0 sc0 ls0 ws0">#include &lt;msp430g2553.h&gt;</div><div class="t m0 x1 h4 y5 ff1 fs0 fc0 sc0 ls0 ws0">#include "typedef.h"</div><div class="t m0 x1 h3 y6 ff1 fs0 fc0 sc0 ls0 ws0">rece_data uart_buf; //<span class="ff2">&#20018;&#21475;&#32531;&#20914;&#21306;</span></div><div class="t m0 x1 h4 y7 ff1 fs0 fc0 sc0 ls0 ws0">void init_uart_buf(void)</div><div class="t m0 x1 h4 y8 ff1 fs0 fc0 sc0 ls0 ws0">{</div><div class="t m0 x1 h4 y9 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;uart_buf.head = 0;</div><div class="t m0 x1 h4 ya ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;uart_buf.tail = uart_buf.head;</div><div class="t m0 x1 h4 yb ff1 fs0 fc0 sc0 ls0 ws0">}</div><div class="t m0 x1 h3 yc ff1 fs0 fc0 sc0 ls0 ws0">//<span class="ff2">&#33719;&#21462;&#20018;&#21475;&#25968;&#25454;</span></div><div class="t m0 x1 h4 yd ff1 fs0 fc0 sc0 ls0 ws0">u8 get_uart_data(u8* data)</div><div class="t m0 x1 h4 ye ff1 fs0 fc0 sc0 ls0 ws0">{</div><div class="t m0 x1 h4 yf ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;if(uart_buf.tail == uart_buf.head)</div><div class="t m0 x1 h4 y10 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;{</div><div class="t m0 x1 h4 y11 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;return 0;</div><div class="t m0 x1 h4 y12 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;}</div><div class="t m0 x1 h4 y13 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;*data = uart_buf.buf[uart_buf.head];</div><div class="t m0 x1 h4 y14 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;uart_buf.head = (uart_buf.head + 1) % BUF_SIZE;</div><div class="t m0 x1 h4 y15 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;return 1;</div><div class="t m0 x1 h4 y16 ff1 fs0 fc0 sc0 ls0 ws0">}</div><div class="t m0 x1 h3 y17 ff1 fs0 fc0 sc0 ls0 ws0">//<span class="ff2">&#20445;&#23384;&#20018;&#21475;&#25968;&#25454;</span></div><div class="t m0 x1 h4 y18 ff1 fs0 fc0 sc0 ls0 ws0">void save_uart_data(u8 data)</div><div class="t m0 x1 h4 y19 ff1 fs0 fc0 sc0 ls0 ws0">{</div><div class="t m0 x1 h4 y1a ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;uart_buf.buf[uart_buf.tail] = data;</div><div class="t m0 x1 h4 y1b ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;uart_buf.tail = (uart_buf.tail + 1) % BUF_SIZE;</div><div class="t m0 x1 h4 y1c ff1 fs0 fc0 sc0 ls0 ws0">}</div><div class="t m0 x1 h3 y1d ff1 fs0 fc0 sc0 ls0 ws0">//<span class="ff2">&#20018;&#21475;&#21021;&#22987;&#21270;</span></div><div class="t m0 x1 h4 y1e ff1 fs0 fc0 sc0 ls0 ws0">void uart_Init(void)</div><div class="t m0 x1 h4 y1f ff1 fs0 fc0 sc0 ls0 ws0">{</div><div class="t m0 x1 h4 y20 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;WDTCTL<span class="_ _1"></span> = WD<span class="_ _1"></span>TPW + <span class="_ _2"></span>WDTHOLD;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;// Stop WDT</div><div class="t m0 x1 h4 y21 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;BCSCTL1 = CALBC1_1MHZ;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;// Set DCO</div><div class="t m0 x1 h4 y22 ff1 fs0 fc0 sc0 ls0 ws0">DCOCTL=CALDCO_1MHZ;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;</div><div class="t m0 x1 h4 y23 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;P1SEL<span class="_ _1"></span> = BIT1 + BIT2 ;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;// P1.1 = RXD, P1.2=TXD</div><div class="t m0 x1 h4 y24 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;P1SEL2 = BIT1 + BIT2 ;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;// P1.1 = RXD, P1.2=TXD</div><div class="t m0 x1 h4 y25 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;</div><div class="t m0 x1 h4 y26 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;UCA0CTL1 |= UCSSEL_2;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;// SMCLK</div><div class="t m0 x1 h4 y27 ff1 fs0 fc0 sc0 ls0 ws0">&amp;&amp;&amp;&amp;UCA0BR0 = 104;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;&amp;// 1MHz 9600</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>
评论
    相关推荐
    • 单片机课件
      能够帮助同学们快速的了解单片机并对于单片机的一些设计程序有一定的认知
    • 单片机课件
      单片机的课件及例题, 单片机的课件及例题, 单片机的课件及例题, 单片机的课 件及例题,
    • 爱上单片机
      一本电子爱好者都能看懂,会边看边笑的单片机入门书籍,作者杜洋曾在《无线电》上发表过“趣味单片机制作专题”、“单片机编程魔法学校”等深受读者喜爱、让无数单片机入门者热血沸腾的系列文章。本书通过生动的语言...
    • 单片机资料
      内含30个单片机应用开发的资料,包括配套单片机入门PPT。
    • 单片机课件
      单片机课的课件,对单片机的基础进行了全面的概述,也有非常精细的指导。
    • 单片机工具
      单片机工具 供单片机学习使用 免费资源 日后还会有更多资源 请联系我
    • 单片机课件
      单片机课件 ppt文件格式 介绍了单片机的结构、程序设计、定时器、中断等
    • 单片机教程
      这是一个单片机的教程,可以用于初次学习单片机的人学习。
    • 单片机入门
      很好的单片机学习资源,入门比较好适合对单片机的学习有兴趣的人,而且是名校的精彩讲解,
    • 爱上单片机
      《爱上单片机》本书是一本电子爱好者都能看懂,会边看边笑的单片机入门书籍,作者杜洋曾在《无线电》上发表过“趣味单片机制作专题”、“单片机编程魔法学校”等深受读者喜爱、让无数单片机入门者热血沸腾的系列文章...