My project requires me to switch between UART and SPI on port A of the msp430g2553. The SPI_initialize and uart_initialize functions are as follows:
void uart_init()
{
P1SEL &= ~BIT4;
P1SEL2 &= ~BIT4;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 = UCSWRST;
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 131; // 1MHz 9600
UCA0BR1 = 6; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
}
void spi_initialize( void )
{
UCA0CTL1 = UCSWRST;
P1DIR |= SOMI + SIMO + SCLK;// SOMI-P1.1, SIMO-P1.2, SCLK-P1.4
P1SEL |= SOMI + SIMO + SCLK;
P1SEL2 |= SOMI + SIMO + SCLK;
UCA0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC;
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 |= 1;
UCA0BR1 |= 0;
UCA0CTL1 &= ~UCSWRST;
}
The uart works for the first time initially but once I initialize SPI and then try to initialize UART once again, the UART module doesn't work any more. Do the uart_init and/or the spi_init functions need to be modified? Any help would be greatly appreciated.