Part Number:MSP430G2553
Tool/software: Code Composer Studio
Hello every,
I am so confused about the UART transmission. I think I make it very simple and get all the necessary set and reset correctly. And the Terminal corresponding Baudrate is also 9600, but I just got nothing at all. Could anyone help me out with this situation. Appreciate so much.
#include <msp430.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
DCOCTL = CALDCO_16MHZ;
BCSCTL1 |= CALBC1_16MHZ;
P1DIR |= BIT2; // set P1.2 Tx output
P1SEL |= BIT1 + BIT2; // select P1.1 Rx, P1.2 Tx to UART function
P1SEL2 |= BIT1 +BIT2;
UCA0CTL1 |= UCSWRST; // **Put state machine in reset **
UCA0CTL1 |= UCSSEL_2; //CLK = SMCLK
UCA0BR0 = 130; // N = 16MHz/9600 = 130 + 6*256
UCA0BR1 = 6;
UCA0MCTL |= UCBRF_0 + UCBRS_6; //slau144j.pdf page 425
UCA0CTL1 &= ~UCSWRST; // **Initialize state machine**
while(1)
{
while(!(IFG2 & UCA0TXIFG)); // TX buffer ready?
UCA0TXBUF = 'A'; // setting TXBUF clears the TXIFG flag
}
}
