//! MSP430F2618 clock and I/O definitions
-// Ought to be portable to other 2xx chips.
-// 2274 looks particularly appealing.
+// Included by other 2xx ports, such as the 2274.
#include "platform.h"
}
+//! Initialize the MSP430 clock.
void msp430_init_dco() {
- //This REQUIRES that info flash be unmolested.
- //TODO check for that.
+ //LED lights when init_dco begins,
+ //then dims when successful.
+ PLEDOUT|=PLEDPIN;
- BCSCTL1 = CALBC1_16MHZ;
- DCOCTL = CALDCO_16MHZ;
+ if(CALBC1_16MHZ!=0xFF && CALDCO_16MHZ!=0xFF){
+ //Info is intact, use it.
+ BCSCTL1 = CALBC1_16MHZ;
+ DCOCTL = CALDCO_16MHZ;
+ }else{
+ //Info is missing, guess at a good value.
+ switch(*((int*)0xff0)){
+ default:
+ case 0x6ff2: //f26f, the MSP430F2618
+ BCSCTL1 = 0x8f; //CALBC1_16MHZ at 0x10f9
+ DCOCTL = 0x7f; //CALDCO_16MHZ at 0x10f8
+ break;
+ }
+ }
+
+ //Hopefully by here the clock is meaningful.
+ PLEDOUT&=~PLEDPIN;
return;
}