1 //! MSP430F2618 clock and I/O definitions
3 // Ought to be portable to other 2xx chips.
4 // 2274 looks particularly appealing.
14 unsigned char serial_rx(){
17 while(!(IFG2&UCA0RXIFG));//wait for a byte
21 //UCA0CTL1 &= ~UCA0RXSE;
26 unsigned char serial1_rx(){
32 void serial_tx(unsigned char x){
33 while ((IFG2 & UCA0TXIFG) == 0); //loop unti lbuffer is free
34 UCA0TXBUF = x; /* send the character */
35 while(!(IFG2 & UCA0TXIFG));
38 //! Transmit a byte on the second UART.
39 void serial1_tx(unsigned char x){
42 //! Set the baud rate.
43 void setbaud(unsigned char rate){
45 //http://mspgcc.sourceforge.net/baudrate.html
66 //! Set the baud rate of the second uart.
67 void setbaud1(unsigned char rate){
69 //http://mspgcc.sourceforge.net/baudrate.html
91 //host.h says 0x2B for DCO=4.9MHZ
92 //Divide by four for accuracy.
99 void msp430_init_uart(){
100 // Serial on P3.4, P3.5
101 P3SEL |= BIT4 + BIT5;
104 //UCA0CTL1 |= UCSWRST; /* disable UART */
107 //UCA0CTL0 |= UCMSB ;
108 UCA0CTL1 |= UCSSEL_2; // SMCLK
109 UCA0BR0 = BAUD0EN; // 115200
111 UCA0MCTL = 0; // Modulation UCBRSx = 5
112 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
117 void msp430_init_dco() {
118 BCSCTL1 = CALBC1_16MHZ;
119 DCOCTL = CALDCO_16MHZ;