1 //! MSP430F2618 clock and I/O definitions
3 // Included by other 2xx ports, such as the 2274.
12 unsigned char serial_rx(){
15 while(!(IFG2&UCA0RXIFG));//wait for a byte
19 //UCA0CTL1 &= ~UCA0RXSE;
24 unsigned char serial1_rx(){
30 void serial_tx(unsigned char x){
31 while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free
32 UCA0TXBUF = x; /* send the character */
33 while(!(IFG2 & UCA0TXIFG));
36 void serial_tx_old(unsigned char x){
37 while ((IFG2 & UCA0TXIFG) == 0); //loop until buffer is free
38 UCA0TXBUF = x; /* send the character */
39 while(!(IFG2 & UCA0TXIFG));
42 //! Transmit a byte on the second UART.
43 void serial1_tx(unsigned char x){
47 //! Set the baud rate.
48 void setbaud(unsigned char rate){
50 //Table 15-4, page 481 of 2xx Family Guide
76 //! Set the baud rate of the second uart.
77 void setbaud1(unsigned char rate){
84 void msp430_init_uart(){
86 // Serial on P3.4, P3.5
90 //UCA0CTL1 |= UCSWRST; /* disable UART */
95 UCA0CTL1 |= UCSSEL_2; // SMCLK
97 //UCA0BR0 = BAUD0EN; // 115200
99 setbaud(5);//default baud, 115200
101 UCA0MCTL = 0; // Modulation UCBRSx = 5
102 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
105 //Leave this commented!
106 //Interrupt is handled by target code, not by bootloader.
111 CALDCO_16MHZ 0xdc CALBC1_16MHZ 0x8e 2274-000.txt
112 CALDCO_16MHZ 0x74 CALBC1_16MHZ 0x8f 2618-000.txt
113 CALDCO_16MHZ 0x6c CALBC1_16MHZ 0x8f 2618-001.txt
114 CALDCO_16MHZ 0x97 CALBC1_16MHZ 0x8f 2618-002.txt
115 CALDCO_16MHZ 0x6c CALBC1_16MHZ 0x8f 2618-003.txt
116 CALDCO_16MHZ 0x95 CALBC1_16MHZ 0x8f 2618-004.txt
117 CALDCO_16MHZ 0xcc CALBC1_16MHZ 0x8e 2618-005.txt
118 CALDCO_16MHZ 0x87 CALBC1_16MHZ 0x8f 2618-006.txt
119 CALDCO_16MHZ 0x96 CALBC1_16MHZ 0x8f 2619-001.txt
122 //! Initialization is correct.
123 void msp430_init_dco_done(){
124 char *choice=(char *) 0x200; //First word of RAM.
128 //! Initialize the MSP430 clock.
129 void msp430_init_dco() {
131 char *choice=(char *) 0x200; //First word of RAM.
132 #ifdef __MSP430_HAS_PORT8__
133 P8SEL = 0; // disable XT2 on P8.7/8
136 if(CALBC1_16MHZ!=0xFF){
137 //Info is intact, use it.
138 BCSCTL1 = CALBC1_16MHZ;
139 DCOCTL = CALDCO_16MHZ;
142 Info is missing, guess at a good value.
144 For now, the choice doesn't jump backward after a successful
145 connection. For that reason, keep this list as small as possible.
146 Future revisions will subtract one from choice[0] after a successful
147 connection, keeping choice[1] as the target.
151 DCOCTL = 0x00; //clear DCO
152 switch(choice[0]++%CHOICES){
155 BCSCTL1 = 0x8f; //CALBC1_16MHZ at 0x10f9
156 DCOCTL = 0x83; //CALDCO_16MHZ at 0x10f8