//*****************************************************************************
// Clock 1
// Uses default DCO at 1MHz
//
// MSP430G2211
// Jed Margolin 2/27/2016.
// Built with Code Composer Studio v6
//*****************************************************************************
// main.c
#include <msp430.h>
#define TIME 6
void wait(unsigned int);
void wait2(void);
//================================================
int main(void)
{
volatile unsigned int k = 0;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
wait(125); // give the crystal (if there is one) 500ms to stabilize
P1SEL |= BIT0; // ACLK for monitoring the crystal
// P1SEL2 &= ~(BIT0); // not used by msp430g2211
P1DIR |= BIT0;
P1SEL &= ~BIT1; // In
// P1SEL2 |= BIT1; // not used by msp430g2211
P1REN |= BIT1; // pullup/pulldown enabled
P1OUT |= BIT1;
P1DIR &= ~(BIT1);
P1SEL &= ~BIT2; // Out
// P1SEL2 |= BIT2; // not used by msp430g2211
P1DIR |= BIT2;
P1SEL &= ~(BIT3); // Out - for testing
// P1SEL2 &= ~(BIT3); // not used by msp430g2211
P1DIR |= BIT3;
P1SEL |= BIT4; // Out for SMCLK so we know it's working
// P1SEL2 &= ~(BIT4); // not used by msp430g2211
P1DIR |= BIT4;
P1SEL &= ~(BIT5); // In
// P1SEL2 &= ~(BIT5); // not used by msp430g2211
P1REN |= BIT5; // pullup/pulldown enabled
P1OUT |= BIT5; // pullup
P1DIR &= ~(BIT5); //
P1SEL &= ~(BIT6); // Out
// P1SEL2 &= ~(BIT6); // not used by msp430g2211
P1DIR |= BIT6; // pullup
P1DIR &= ~(BIT7); // In
P1OUT |= BIT7; // pullup
P1SEL &= ~(BIT7);
// P1SEL2 &= ~(BIT7); // not used by msp430g2211
P1REN |= BIT7; // pullup/pulldown enabled
#if 1 // Make this '0' to compare factory calibration with no calibration
// You might have to unplug power to the board to actually reset this
// The 2211 has factory calibration constants only for 1MHz
if(CALBC1_1MHZ != 0xFF) // If it has been erased don't use
// the calibration constants
{
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
P1OUT &= ~BIT2; // clear it
}
else // Set P1.2 high if the 1MHz calibration values have been erased
{
P1OUT |= BIT2;
}
#endif
//-----------------------
while (1) // main loop
{
P1OUT |= BIT6;
wait(125);
P1OUT &= ~(BIT6);
wait(125);
} // end main loop
} // end main
//==================================
void wait(unsigned int time)
{
volatile unsigned int i,j;
for(i=time; i>0; i--)
{
for(j=392; j>0; j--);
{
}
}
return;
} // end main
//==========================================================
void wait2()
{
volatile unsigned int i;
for(i=0; i<48; i++){}
return;
}
//========================================================