1 //! MSP430F2618 clock and I/O definitions
3 // Included by other 2xx ports, such as the 2274.
14 unsigned char serial0_rx(){
17 while(!(IFG2&UCA0RXIFG));//wait for a byte
21 //UCA0CTL1 &= ~UCA0RXSE;
26 unsigned char serial1_rx(){
32 void serial0_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 setbaud0(unsigned char rate){
52 //Table 15-4, page 481 of 2xx Family Guide
78 //! Set the baud rate of the second uart.
79 void setbaud1(unsigned char rate){
86 void msp430_init_uart(){
88 // Serial on P3.4, P3.5
92 //UCA0CTL1 |= UCSWRST; /* disable UART */
97 UCA0CTL1 |= UCSSEL_2; // SMCLK
99 //UCA0BR0 = BAUD0EN; // 115200
101 setbaud(5);//default baud, 115200
103 UCA0MCTL = 0; // Modulation UCBRSx = 5
104 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
107 //Leave this commented!
108 //Interrupt is handled by target code, not by bootloader.
113 //! Initialization is correct.
114 void msp430_init_dco_done(){
115 char *choice=(char *) 0x200; //First word of RAM.
119 //! Initialize the MSP430 clock.
120 void msp430_init_dco() {
122 char *choice=(char *) 0x200; //First word of RAM.
124 #ifdef __MSP430_HAS_PORT8__
125 P8SEL = 0; // disable XT2 on P8.7/8
128 //Set P2.6 mode for MSP430F2274
129 #ifndef __MSP430_HAS_PORT5__
130 P2SEL = 0; //disable XIN on 2274
134 if(CALBC1_16MHZ!=0xFF){
135 //Info is intact, use it.
136 BCSCTL1 = CALBC1_16MHZ;
137 DCOCTL = CALDCO_16MHZ;
140 Info is missing, guess at a good value.
142 A list of correct calibrations in included as dco_calib.c,
145 DCOCTL = 0x00; //clear DCO
147 BCSCTL1 = dco_calibrations[2*choice[0]+1];
148 DCOCTL = dco_calibrations[2*choice[0]];
150 choice[0]%=dco_calibrations_count;