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){
80 //http://mspgcc.sourceforge.net/baudrate.html
103 void msp430_init_uart(){
105 // Serial on P3.4, P3.5
106 P3SEL |= BIT4 + BIT5;
109 //UCA0CTL1 |= UCSWRST; /* disable UART */
112 //UCA0CTL0 |= UCMSB ;
114 UCA0CTL1 |= UCSSEL_2; // SMCLK
116 //UCA0BR0 = BAUD0EN; // 115200
118 setbaud(5);//default baud, 115200
120 UCA0MCTL = 0; // Modulation UCBRSx = 5
121 UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
124 //Leave this commented!
125 //Interrupt is handled by target code, not by bootloader.
130 CALDCO_16MHZ 0xdc CALBC1_16MHZ 0x8e 2274-000.txt
131 CALDCO_16MHZ 0x74 CALBC1_16MHZ 0x8f 2618-000.txt
132 CALDCO_16MHZ 0x6c CALBC1_16MHZ 0x8f 2618-001.txt
133 CALDCO_16MHZ 0x97 CALBC1_16MHZ 0x8f 2618-002.txt
134 CALDCO_16MHZ 0x6c CALBC1_16MHZ 0x8f 2618-003.txt
135 CALDCO_16MHZ 0x95 CALBC1_16MHZ 0x8f 2618-004.txt
136 CALDCO_16MHZ 0xcc CALBC1_16MHZ 0x8e 2618-005.txt
137 CALDCO_16MHZ 0x87 CALBC1_16MHZ 0x8f 2618-006.txt
138 CALDCO_16MHZ 0x96 CALBC1_16MHZ 0x8f 2619-001.txt
141 //! Initialize the MSP430 clock.
142 void msp430_init_dco() {
143 if(CALBC1_16MHZ!=0xFF){
144 //Info is intact, use it.
145 BCSCTL1 = CALBC1_16MHZ;
146 DCOCTL = CALDCO_16MHZ;
148 //Info is missing, guess at a good value.
149 switch(*((int*)0xff0)){
151 case 0x6ff2: //f26f, the MSP430F2618
156 BCSCTL1 = DCOVAL; //CALBC1_16MHZ at 0x10f9
157 /** Observed DCOCTL values:
160 DCOCTL = 0x83; //CALDCO_16MHZ at 0x10f8