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.

CCS/CC430F6137: UART Reading

Part Number: CC430F6137

Tool/software: Code Composer Studio

Hi everyone,

I'm trying to establish UART communication. I can send data from CC430F6137 to other MCU .However I  couldn't handle receive operation. I'm sure that other MCU sends the data through UART Tx pin , but I couldn't get this datas from CC430 Rx pin.

My code is that :

#include <stdio.h>
#include <msp430.h>
#include "cc430x613x.h"

char buffer_0[5] ;
char terminal_read();

int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
UART_open();
UCA0IE |= UCRXIE ;

while(1){
terminal_read();
// __delay_cycles(1e5);
}



return 0;
}
char terminal_read(){
char c ;
while (!(UCA0IFG & UCRXIFG));
c = UCA0RXBUF ;
printf("%c" , &c);
return UCA0RXBUF;
}


void terminal_write(char *info)
{
unsigned int i;


unsigned int len = strlen(info) ;
for(i=0;i<len;i++)
{

UCA0TXBUF=info[i];
__delay_cycles(10000);

}
}

void UART_open(){
P1SEL |= BIT5 + BIT6;
//UART Settings
UCA0CTL1 |= UCSWRST;
UCA0CTL1 |= UCSSEL0 ; // ACLK
UCA0BR0=3; //UCA0BR0 = 3 ; //32Khz / 9600 –>> 3
UCA0BR1=0; //UCA0BR1=0; // BAUD 9600; ( UCABR1 * 256 ) + UCABR0 = UCABRx see "slau259e.pdf"

UCA0MCTL=UCBRS0 + UCBRS1 ; // see "slau259e.pdf" page 602 //
//UCA0MCTL =| BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2 | BIT1 | BIT0 |
// |------- UCBRFx --------------|----UCBRSx----------|UCOS16|
// for 9600 baudrate at 32kHz UCBRFx = 0 , UCBRSx = 3 , UCOS16 = 0
// | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 |
// 0b00000110 = 0x06 = 6
UCA0CTL1 &=~ UCSWRST;//
// UCA0CTL1 |= UCDORM;
}

void UART_close(){

P1SEL &= ~(BIT5 + BIT6);
P1DIR |= BIT5 + BIT6;
P1OUT &= ~(BIT5 + BIT6);
UCA0CTL1 |= UCSWRST;
UCA0CTL1 &=~ UCDORM;

}

char* String_int(int data){
char* ret_data;
ret_data = ltoa(data , buffer_0 , 10 );
return ret_data;
}

What's wrong with my code? I always read the UCRXIFG as '0'. So 'terminal_read' function always stuck on this line.

**Attention** This is a public forum