EasyManua.ls Logo

Texas Instruments MSP430

Texas Instruments MSP430
413 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
376
* UCSWRST -- Enabled. USCI logic held in reset state
*
* Note: ~<BIT> indicates that <BIT> has value zero
*/
UCA0CTL1 = UCSSEL_2 | UCSWRST;
/*
* Modulation Control Register
*
* UCBRF_0 -- First stage 0
* UCBRS_1 -- Second stage 1
* ~UCOS16 -- Disabled
*
* Note: ~UCOS16 indicates that UCOS16 has value zero
*/
UCA0MCTL = UCBRF_0 | UCBRS_1;
/* Baud rate control register 0 */
UCA0BR0 = 104;
/* Enable USCI */
UCA0CTL1 &= ~UCSWRST;
Right after initialization of all required hardware, the UART starts sending some strings.
UART_puts("\f");
UART_puts("MSP430G2553 UART Demo\n");
UART_puts("Shawon Shahryiar\n");
UART_puts("https://www.facebook.com/MicroArena\n");
The following functions transmit data via UART. The first one can transmit one character at a time
while the second can transmit a string of characters. In both cases, it is checked if the last character
has been successfully sent before sending a new character.
void UART_putc(char ch)
{
while(!(IFG2 & UCA0TXIFG));
UCA0TXBUF = ch;
}
void UART_puts(char *str)
{
while(*str != 0)
{
while(!(IFG2 & UCA0TXIFG));
UCA0TXBUF = *str++;
};
}
Since data recption interrupt is used, data received is extracted from UART reception ISR.
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR_HOOK(void)
{
rx = UCA0RXBUF;
}

Table of Contents

Other manuals for Texas Instruments MSP430

Related product manuals