The Serial Port of MSP430 is almost always used in any MSP430 design. The serial port can be used for communication with computer and with other devices supporting serial ports.
Serial Port Transmitter
Let us write a code that will output englisg characters A to Z repeatedly on the Serial Port of the MSP430. If you hook up a Serial TTL to RS232 converter then you should be able to see these characters on the hyperterminal of your computer. If you do not have a TTL to RS232 converter you should be able to monitor the bits going out of MSP430 on a oscilloscope.
//****************************************************************************** // MSP430F149 Programming Tutorial - Understanding Serial Port // // This program Transmits Character A to Z on Hyperterminal at 9600-baud UART using // USART0 and a 32.768 kHz crystal. // Baud rate divider with 32.768 Khz XTAL // @9600 = 32768Hz/9600 = 3.41 => UBR00 = 0x03; UBR01 = 0x03; // //* An external 32.768KHz crystal is required on XIN XOUT *// // // MSP430F149 // ----------------- // /|\| XIN|- // | | | 32.768kHz // --|RST XOUT|- // | | // | P3.4|-----------> // | | 9600 - 8N1 // | P3.5|<----------- // // referencedesigner.com tutorial //******************************************************************************
#include <msp430x14x.h>
void delay(unsigned int ms) { unsigned int i, j; for (i = 0; i <= ms; i++) { for (j = 0; j<=255; j++); } }
{ for (i = 0x41; i <= 0x5A ; i++) { while (!(IFG1 & UTXIFG0)); TXBUF0 = i; delay(100); } }
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/ interrupt }
Copy paste this code in your IAR embedder system and run the code. I am assuming that you connect a TTL to RS232 converter between P3.4 and the input ( Pin 2 ) of the DB9 serial port connector of your computer. If you open the hyperterminal then you shoul see something like this on your Hyperterminal