Other Parts Discussed in Thread: MSP430G2553
Hi,
I am trying to learn the UART communications on MSP430G2553 and beginner. Please answer the following questions of me
1. Can UART communication be done through the default USB connection to emulator or is it necessary to use RS232 to USB converter ? Several blogs suggested USB emulator connection is sufficient for UART. If yes, please explain USB emulator connection works for UART.
2. Assuming USB emulator connection works, I tried using hyperterminal for windows 7. I can see MSP430 assigned COM13 port in device manager but however I am not able to establish connection in hyperterminal. I tried using Putty but I wasnt able to open after giving serial port settings.
3. Below is the my code for Transmitting data.
#include <msp430.h>
/*
* main.c
*/
char message[6]="Hello";
void config_UART(void);
void config_clock(void);
int main(void) {
unsigned int i;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
config_clock();
config_UART();
_EINT(); //Enable Global Interrupt Bit
UCA0CTL1=UCA0CTL1 & 0xFE; //Enable UART Operation
IE2 = 0x2; //Enable Tx Interrupt
for(i=0;message[i]!='\n';i++)
{
UCA0TXBUF=message[i]; //Fill Buffer with Data
while(IFG2 & 0x02==1); //Wait till the data transmitted.
}
}
void config_clock(void)
{
BCSCTL1=CALBC1_1MHZ; //Setting clock of 1 MHz.
DCOCTL=CALDCO_1MHZ;
}
void config_UART(void)
{
UCA0CTL0=0x00; //Settings for Standard UART communications.
UCA0CTL1=0XC1; //Selecting SMCLK as source for UART clock
UCA0BR0=0x68; // Baudrate 9600 settings at clock of 1 MHz
UCA0BR1=0x00;
P1SEL=0x06; // Configuring Ports for UART Tx and Rx operation
P1SEL2=0x06;
}
#pragma vector=USCIAB0TX_VECTOR
__interrupt void UART_TX(void)
{
}
I feel I dont understand the working of Tx Interrupt flag and feel my logic is not correct after transmitting data(the one with while loop). Please explain me how TxIFG flag is set or reset when data is written to TxBuffer. As of now, i feel TxIFG flag is reset when data is transmitted and is set when data is written to buffer. With the above code, its always struck in the ISR and doesnt come out.
Thanks and regards,
Shivakumar
