Hi,
I am having troubles in trying to send and receive the same data that I input from Hyper Terminal. I am using 9600baud rate at 300kHz. I assume that HyperTerminal sends a signal through the RS232 to start the sequence for UART.
HyperTerminal Settings:
I have 3 pins connected to the RS232 which are TX and RX and GND. Is there one I am missing?
this is my code below:
void main(void) {
int i;
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
SCFI0 |= FN_2;
SCFI0 &= ~BIT6;
SCFI0 |= BIT7;
P1SEL |= (BIT1 + BIT4);
P1DIR |= (BIT1 + BIT4);
P1OUT |= (BIT1 + BIT4);
P2SEL |= (BIT4 + BIT5); // USART TX(2.4)pin55, RX (2.5) pin54
P2DIR |= BIT4; // Output for TX
UCTL0 |= (SWRST);
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= (SSEL1); // UCLK = SMCLK
ME1 |= UTXE0 + URXE0; // Enable USART0 TXD/RXD
U0BR0 = 0x31; // for 9600 baud rate at 300kHz
U0BR1 = 0x00;
UMCTL0 = 0x03; // modulation
UCTL0 &= ~SWRST; // start state machine for USART
IE1 |= URXIE0;// + UTXIE0; // Enable USART0 RX/TX interrupt
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt
}
#pragma vector=USART0RX_VECTOR
__interrupt void usart0_rx (void)
{
while (!(IFG1 & UTXIFG0)); // USART0 TX buffer ready?
TXBUF0 = RXBUF0; // RXBUF0 to TXBUF0
}