I am working on a project that involves serial communication between MSP430f1232 and PC at the baud rate of 38400 b/s. I am able to receive data at the PC end from the MSP430 but have no success in receiving data at the microcontroller end from the PC.
The microcontroller has a crystal frequency of 4.00 MHz. I am using IAR Embedded Workbench for development.
The initialization of USART0 is done using the following code:
/*
Initialization values for UxBR and UxMCTL registers
to set the baud rate to 38.4 KHz assuming BRCLK = 4 MHz.
These values are calculated using the formulae given in MSP430 userguide.
*/
#define UART_BAUD 0x0068
#define MODULATION_VAL 0x08
/*
Initialize USART0 as UART
*/
UCTL0 = SWRST; // Reset USART
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL0; // UCLK = ACLK
UBR00 = UART_BAUD & 0xff; // Configure baud rate
UBR10 = (UART_BAUD >> 8) & 0xff;
UMCTL0 = MODULATION_VAL; // Enable modulation
ME2 |= UTXE0 | URXE0; // Enable UART TXD/RXD
UCTL0 &= ~SWRST; // Release USART
IE2 |= URXIE0; // Enable USART RX interrupt
The ISR to for reception of data is as below:
#pragma vector=USART0RX_VECTOR
__interrupt void UART0_recv_handler(void)
{
unsigned char rx_data;
// Read the UART receive buffer
rx_data = RXBUF0;
}
Help is urgently required. Thanx in advance,
Anand