This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430G2553 UART 115200 with 16MHz clock

I wrote the following code to actuvate the UART pheripheral but I believe there is something wrong ive done. But im unable to spot the same.

here is my code

void ConfigSystemClock (void){
BCSCTL1= DIV_ACLK_8 +CALBC1_16MHZ; 
BCSCTL2= MCLK_SOURCE_DCO + DIV_MCLK_1 + SMCLK_SOURCE_DCO;
BCSCTL3= USE_VLO_AS_LFXT1 + CAP_ACCROSS_XT_125PF;
DCOCTL = CALDCO_16MHZ;return;} 

void UARTOFF (void) {
UCA0CTL1 |= 0X01; // PUT the USCI machine back to POR/OFF State
return;
}
void UARTON (void){
UCA0CTL1 = UCSSEL_2 ; // last bit becomes zero automatically starting the UART machine
return;


void UARTInit (void) {
/* When UCA0RXIE bit is cleared (made zero) USCI enabled.Transmitter ready in IDLE state.
* But when data is written to UCAxTXBUF the baudrate generator enables. then the data in the
* UCAxTXBUF is moved into the TX shift register.
* UCAxTXIFG is SET when new data CAN be written to the Buffer.
* when there is no new data, Baud Generator stops. Machine goes back to IDLE
* READ : 15.3.9.1 Low-Frequency Baud Rate Generation
* READ : 15.3.14 Using the USCI Module in UART Mode with Low Power Modes
* The USCI has one interrupt vector for transmission and one interrupt vector for reception.
*/
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 8; 
UCA0BR1 = 0; 
UCA0MCTL = 176 ; 
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
//IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt
return;}

void SendString (char StringBuff []) {

i=0;
while (StringBuff [i] != '\0') {
UCA0TXBUF = StringBuff [i] ;
//_delay_cycles(40000);
while (!(IFG2&UCA0TXIFG));
i++;
}
return;}

these are the functions im calling to UART to a SIM908. 
is there anything wrong with my configuration?

I would so much appreciate help. thank you. 

  • Samiru Thakshila said:
    I believe there is something wrong ive done.

    Why do you think that? What did you expect and what did you observe (and how)?
    Just posting your code (which is good - others keep it secret and expect to get help) and saying "I think it's not working, so what's wrong" doesn't give any clue about where to look for the problem.

**Attention** This is a public forum