MSP430G2553测试程序(串口程序,USCI模式)
2016-08-15 来源:eefocus
// HW UART(J4)!!!!!! 特别注意,板子上J4有2个跳线要竖放,设为HW UART模式
// MSP430G2xx3 Demo - USCI_A0, 9600 UART Echo ISR, DCO SMCLK
//
// Description: Echo a received character, RX ISR used. Normal mode is LPM0.
// USCI_A0 RX interrupt triggers TX Echo.
// Baud rate divider with 16MHz
// ACLK = n/a, MCLK = SMCLK = CALxxx_16MHZ = 16MHz
//
// MSP430G2xx3
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.2/UCA0TXD|------------>
// | | 9600 - 8N1
// | P1.1/UCA0RXD|<------------
//
// 修改http://jiwm.blog.163.com
//串口调试助手,下载地址:http://www.sudt.com/download/AccessPort137.zip
// Texas Instruments Inc.
// February 2011
// Built with IAR Embedded Workbench Version: 5.40
//******************************************************************************
#include 'msp430g2553.h'
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_16MHZ; // Set DCO
DCOCTL = CALDCO_16MHZ;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2;
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 0x82; // 16MHz 9600 UCA0BRX=1666=0x0682
UCA0BR1 = 0x06; // 16MHz 9600
UCA0MCTL = UCBRS2 + UCBRS1; // Modulation UCBRSx = 6
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
}
// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = UCA0RXBUF; // TX -> RXed character
}
上一篇:msp430单片机测量频率
下一篇:软件延时的误区
- msp430g2553+pcf8574+dht11+lcd1602
- 基于MSP430G2553的模拟风扇控制系统
- MSP430G2553 PWM控制速度,并自我检测和简单调节速度
- 利用MSP430G2553测量信号幅度
- 利用MSP430G2553测量信号频率(频率计)
- 基于MSP430G2553和MATLAB Appdesigner的心电信号复现和心率显示
- MSP430G2553 频率、占空比、脉冲宽度测量
- MSP430G2553 移植 Contiki RTOS 实时操作系统
- 【MSP430G2553】图形化开发笔记(1) 配置环境
- 【MSP430G2553】图形化开发笔记(2) 系统时钟和低功耗模式