2552 views|2 replies

7

Posts

0

Resources
The OP

msp4784 serial port [Copy link]

I am a novice, and I have some questions when I ask for guidance from experts:

#include "msp430x47x4.h"
void usart();
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
FLL_CTL0 |= XCAP14PF; // Configure load caps
TACTL= TASSEL_1+ID_3 + MC_1+TACLR; // Select ACLK as the clock source of timer A, divide by 8, up counting mode
CCTL0 = CCIE; // Enable CCR0 interrupt
CCR0 = 2047; // Set period 0.5
usart();
P2DIR=0x02;
_EINT();
for(;;)
{
_BIS_SR(CPUOFF);
_NOP();
}

}
void usart(void)
{
UCA0CTL0 |= UCSWRST;
UCA0CTL0 |= UCSSEL_1; // CLK = ACLK,32768HZ
UCA0BR0 = 0x03; // 9600
UCA0BR1 = 0x00; //
UCA0MCTL = 0x4A; // Modulation
P2SEL |= 0x30; // P2.4,5 = USCI_A0 RXD/TXD
P2DIR|=0x10;
IE2=UCA0RXIE+UCA0TXIE;
UCA0CTL0 &= ~UCSWRST; // **Initialize USCI state machine**
}

// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
P2OUT^=0x02;
//while ((IFG2 & UCA0TXIFG) == 0);
UCA0TXBUF =0x01; // TX -> RXed character

}

This post is from Microcontroller MCU

Latest reply

What's the problem? Describe the phenomenon.  Details Published on 2012-4-8 20:14

424

Posts

0

Resources
2
What's the problem? Describe the phenomenon.
This post is from Microcontroller MCU

7

Posts

0

Resources
3
The serial debugging assistant shows garbled characters before the program is run. Even if debugging is stopped, the serial debugging assistant keeps receiving data. A similar situation occurs when another version of the serial debugging assistant is used. The crystal oscillator is tested and is normal.
This post is from Microcontroller MCU

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

Related articles more>>

    EEWorld
    subscription
    account

    EEWorld
    service
    account

    Automotive
    development
    circle

    Robot
    development
    community

    Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
    快速回复 返回顶部 Return list