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 until buffer is free
34 UCA0TXBUF = x; /* send the character */
35 while(!(IFG2 & UCA0TXIFG));
38 void serial_tx_old(unsigned char x){
39 while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free
40 UCA0TXBUF = x; /* send the character */
41 while(!(IFG2 & UCA0TXIFG));
44 //! Transmit a byte on the second UART.
45 void serial1_tx(unsigned char x){
49 //! Set the baud rate.
50 void setbaud(unsigned char rate){
52 //http://mspgcc.sourceforge.net/baudrate.html
73 //! Set the baud rate of the second uart.
74 void setbaud1(unsigned char rate){
76 //http://mspgcc.sourceforge.net/baudrate.html
104 void msp430_init_uart(){
106 // Serial on P3.4, P3.5
107 P3SEL |= BIT4 + BIT5;
110 //UCA0CTL1 |= UCSWRST; /* disable UART */
113 //UCA0CTL0 |= UCMSB ;
114 UCA0CTL1 |= UCSSEL_2; // SMCLK
115 UCA0BR0 = BAUD0EN; // 115200
117 UCA0MCTL = 0; // Modulation UCBRSx = 5
118 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
121 //Leave this commented!
122 //Interrupt is handled by target code, not by bootloader.
129 void msp430_init_dco() {
130 BCSCTL1 = CALBC1_16MHZ;
131 DCOCTL = CALDCO_16MHZ;