MSP430F149的串口RS232接口.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
MSP430F149的串口RS232接口

MSP430F149的串口RS232接口 1、????? 概述 ??? ?具有同步串口模式(SPI),异步通信模式(UART)。 作异步通信时,P3.4,P3.5,P3.6,P3.7第二功能分别是UTXD0, URXD0, UTXD1, UTXD2 2、????? 使用方法概述 2.1 程序架构 配置寄存器设置工作模式 { 设置IO口为第二功能作为串口收发引脚; 使能串口收发功能; 选择每帧数据位为7或8; 选择波特率发生器时钟源; 配置波特率(查表得出值再配置UxBR0, UxBR1,UxMCTL); 软件清除串口复位位(SWRST); 若采用中断方式则使能接受、发送中断 } ?? 编写接受/发送程序,可采用查询方式或中断方式。同51单片机不同的是,UTXIFG,URXIF在发送下一个数据和读取数据时被自动清零了,无需软件清除。 2.2 细节描述 ?? 配置波特率时用户手册上有速查表,如下 设置波特率时要选择合适的时钟源。对于较低的波特率(9600b/s及以下),可选ACLK,大于9600要选用SMCLK,因为串口波特率发生器分频系数要求大于3。UxBR0(低)UxBR1(高)值的计算式为:选择的时钟源/波特率,再取整。为了精确,MSP430设置了小数分频功能,通过UxMCTL来完成。 3、相关寄存器 1.ME1, Module Enable Register 1 UTXE0 Bit 7 USART0 transmit enable. This bit enables the transmitter for USART0. 0 Module not enabled 1 Module enabled URXE0 Bit 6 USART0 receive enable. This bit enables the receiver for USART0. 0 Module not enabled 1 Module enabled 2.UxCTL(UCTLx), USART Control Register CHAR Bit 4 Character length. Selects 7-bit or 8-bit character length. 0 7-bit data 1 8-bit data SWRST Bit 0 Software reset enable 0 Disabled. USART reset released for operation 1 Enabled. USART logic held in reset state 3.UxTCTL(UTCTLx), USART Transmit Control Register SSELx Bits 5-4 Source select. These bits select the BRCLK source clock. 00 UCLKI 01 ACLK 10 SMCLK 11 SMCLK 4.UxBR0, USART Baud Rate Control Register 0,低8位 ? UxBR1, USART Baud Rate Control Register 1,高8位 5. UxMCTL, USART Modulation Control Register UxMCTLx Bits 7?0 Modulation bits. These bits select the modulation for BRCLK. 6.IFG1, Interrupt Flag Register 1 UTXIFG0 Bit 7 USART0 transmit interrupt flag. UTXIFG0 is set when U0TXBUF is empty. 0 No interrupt pending 1 Interrupt pending URXIFG0 Bit 6 USART0 receive interrupt flag. URXIFG0 is set when U0RXBUF has received a complete character. 0 No interrupt pending 1 Interrupt pending 7.IE1, Interrupt Enable Register 1 UTXIE0 Bit 7 USART0 transmit interrupt enable. This bit enables the UTXIFG0 interrupt. 0 Interrupt not enabled 1 Interrupt enabled URXIE0 Bit 6 USART0 receive interrupt enable. This bit enab

您可能关注的文档

文档评论(0)

xy88118 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档