1 //! MSP430F2618 clock and I/O definitions
3 // Included by other 2xx ports, such as the 2274.
13 unsigned char serial_rx(){
16 while(!(IFG2&UCA0RXIFG));//wait for a byte
20 //UCA0CTL1 &= ~UCA0RXSE;
25 unsigned char serial1_rx(){
31 void serial_tx(unsigned char x){
32 while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free
33 UCA0TXBUF = x; /* send the character */
34 while(!(IFG2 & UCA0TXIFG));
37 void serial_tx_old(unsigned char x){
38 while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free
39 UCA0TXBUF = x; /* send the character */
40 while(!(IFG2 & UCA0TXIFG));
43 //! Transmit a byte on the second UART.
44 void serial1_tx(unsigned char x){
48 //! Set the baud rate.
49 void setbaud(unsigned char rate){
51 //Table 15-4, page 481 of 2xx Family Guide
77 //! Set the baud rate of the second uart.
78 void setbaud1(unsigned char rate){
85 void msp430_init_uart(){
87 // Serial on P3.4, P3.5
91 //UCA0CTL1 |= UCSWRST; /* disable UART */
96 UCA0CTL1 |= UCSSEL_2; // SMCLK
98 //UCA0BR0 = BAUD0EN; // 115200
100 setbaud(5);//default baud, 115200
102 UCA0MCTL = 0; // Modulation UCBRSx = 5
103 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
106 //Leave this commented!
107 //Interrupt is handled by target code, not by bootloader.
112 CALDCO_16MHZ 0xdc CALBC1_16MHZ 0x8e 2274-000.txt
113 CALDCO_16MHZ 0x74 CALBC1_16MHZ 0x8f 2618-000.txt
114 CALDCO_16MHZ 0x6c CALBC1_16MHZ 0x8f 2618-001.txt
115 CALDCO_16MHZ 0x97 CALBC1_16MHZ 0x8f 2618-002.txt
116 CALDCO_16MHZ 0x6c CALBC1_16MHZ 0x8f 2618-003.txt
117 CALDCO_16MHZ 0x95 CALBC1_16MHZ 0x8f 2618-004.txt
118 CALDCO_16MHZ 0xcc CALBC1_16MHZ 0x8e 2618-005.txt
119 CALDCO_16MHZ 0x87 CALBC1_16MHZ 0x8f 2618-006.txt
120 CALDCO_16MHZ 0x96 CALBC1_16MHZ 0x8f 2619-001.txt
123 //! Initialize the MSP430 clock.
124 void msp430_init_dco() {
125 char *choice=(char *) 0x200; //First word of RAM.
126 #ifdef __MSP430_HAS_PORT8__
127 P8SEL = 0; // disable XT2 on P8.7/8
130 if(CALBC1_16MHZ!=0xFF){
131 //Info is intact, use it.
132 BCSCTL1 = CALBC1_16MHZ;
133 DCOCTL = CALDCO_16MHZ;
135 //Info is missing, guess at a good value.
137 DCOCTL = 0x00; //clear DCO
138 switch(choice[0]++%CHOICES){
141 BCSCTL1 = 0x8f; //CALBC1_16MHZ at 0x10f9
142 DCOCTL = 0x83; //CALDCO_16MHZ at 0x10f8