|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区
您需要 登录 才可以下载或查看,没有账号?立即注册
×
#include <msp430.h>
static char String1[] = { "Hello World\r\n" };
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog
//.......................
P5SEL |= BIT4+BIT5; // Select XT1
UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
UCSCTL3 = 0; // FLL Reference Clock = XT1
// Loop until XT1,XT2 & DCO stabilizes - In this case loop until XT1 and DCo settle
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive strength
UCSCTL4 |= SELA_0 + SELS_4 + SELM_4; // ACLK = LFTX1
// SMCLK = default DCO
// MCLK = default DCO
//................
P4SEL = BIT4+BIT5; // P4.4,5 = UART1 TXD/RXD
// configure USCI_A1 UART
UCA1CTL1 = UCSSEL_1; // ACLK
UCA1BR0 = 0x03; // 32768Hz 9600 32k/9600=3.41
UCA1BR1 = 0x0;
UCA1MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx = 3
UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
// configure DMA0
DMACTL0 = DMA0TSEL_1; // 0-CCR2IFG
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) String1);
// Source block address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA1TXBUF);
// Destination single address
DMA0SZ = sizeof String1-1; // Block size
DMA0CTL = DMADT_4 + DMASRCINCR_3 + DMASBDB + DMAEN;// Rpt, inc src, enable
TA0CCR0 = 8192; // Char freq = TACLK/CCR0
TA0CCR2 = 1; // For DMA0 trigger
TA0CTL = TASSEL_1 + MC_1; // ACLK, up-mode
__bis_SR_register(LPM3_bits); // Enter LPM3
} |
|