+ int i=1000;
+ char *choice=(char *) 0x200; //First word of RAM.
+
+ #ifdef __MSP430_HAS_PORT8__
+ P8SEL = 0; // disable XT2 on P8.7/8
+ #endif
+
+ //Set P2.6 mode for MSP430F2274
+ #ifndef __MSP430_HAS_PORT5__
+ P2SEL = 0; //disable XIN on 2274
+ #endif
+
+
+ if(CALBC1_16MHZ!=0xFF){
+ //Info is intact, use it.
+ BCSCTL1 = CALBC1_16MHZ;
+ DCOCTL = CALDCO_16MHZ;
+ }else{
+ /*
+ Info is missing, guess at a good value.
+
+ A list of correct calibrations in included as dco_calib.c,
+ generated by script.
+ */
+ DCOCTL = 0x00; //clear DCO
+
+ BCSCTL1 = dco_calibrations[2*choice[0]+1];
+ DCOCTL = dco_calibrations[2*choice[0]];
+ choice[0]++;
+ choice[0]%=dco_calibrations_count;
+ }
+
+ //Minor delay.
+ while(i--);
+
+