1 //! MSP430F2618 clock and I/O definitions
3 // Included by other 2xx ports, such as the 2274.
18 unsigned char serial0_rx(){
21 while(!(IFG2&UCA0RXIFG));//wait for a byte
25 //UCA0CTL1 &= ~UCA0RXSE;
30 unsigned char serial1_rx(){
36 void serial0_tx(unsigned char x){
37 while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free
38 UCA0TXBUF = x; /* send the character */
39 while(!(IFG2 & UCA0TXIFG));
42 void serial_tx_old(unsigned char x){
43 while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free
44 UCA0TXBUF = x; /* send the character */
45 while(!(IFG2 & UCA0TXIFG));
48 //! Transmit a byte on the second UART.
49 void serial1_tx(unsigned char x){
53 //! Set the baud rate.
54 void setbaud0(unsigned char rate){
56 //Table 15-4, page 481 of 2xx Family Guide
82 //! Set the baud rate of the second uart.
83 void setbaud1(unsigned char rate){
90 void msp430_init_uart(){
92 // Serial on P3.4, P3.5
96 //UCA0CTL1 |= UCSWRST; /* disable UART */
101 UCA0CTL1 |= UCSSEL_2; // SMCLK
103 //UCA0BR0 = BAUD0EN; // 115200
105 setbaud(5);//default baud, 115200
107 UCA0MCTL = 0; // Modulation UCBRSx = 5
108 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
111 //Leave this commented!
112 //Interrupt is handled by target code, not by bootloader.
117 //! Initialization is correct.
118 void msp430_init_dco_done(){
119 char *choice=(char *) 0x200; //First word of RAM.
123 //! Initialize the MSP430 clock.
124 void msp430_init_dco() {
126 char *choice=(char *) 0x200; //First word of RAM.
128 #ifdef __MSP430_HAS_PORT8__
129 P8SEL = 0; // disable XT2 on P8.7/8
132 //Set P2.6 mode for MSP430F2274
133 #ifndef __MSP430_HAS_PORT5__
134 P2SEL = 0; //disable XIN on 2274
139 BCSCTL1 = (STATICDCO>>8);
140 DCOCTL = (STATICDCO&0xFF);
142 if(CALBC1_16MHZ!=0xFF){
143 //Info is intact, use it.
144 BCSCTL1 = CALBC1_16MHZ;
145 DCOCTL = CALDCO_16MHZ;
148 Info is missing, guess at a good value.
150 A list of correct calibrations in included as dco_calib.c,
153 DCOCTL = 0x00; //clear DCO
155 BCSCTL1 = dco_calibrations[2*choice[0]+1];
156 DCOCTL = dco_calibrations[2*choice[0]];
158 choice[0]%=dco_calibrations_count;