// Chip msp430f149
# Include "io430.h"
// Define the clock speed
# Define cpu_f (double) 8000000)
// Define the latency Function
# Define delay_us (x) _ delay_cycles (long) (cpu_f * (double) x/1000000.0 ))
# Define delay_ms (x) _ delay_cycles (long) (cpu_f * (double) x/1000.0 ))
Void main (void)
{
Unsigned char I;
Wdtctl = wdtpw + wdthold;
P2dir | = 0x01;
P5dir | = 0x70;
Bcsctl1 & = ~ Xt2off;
Bcsctl1 + = 0x30;
Do
{
Ifg1 & = ~ Ofifg;
For (I = 0xff; I> 0; I --);
}
While (ifg1 & ofifg );
Bcsctl2 | = selm_2;
// Mclk (the main system clock adopts an External High-Frequency Crystal Oscillator)
// Smclk (subsystem clock adopts internal DCO Oscillator)
// Aclk (the clock of the auxiliary system uses an external Low Frequency Crystal Oscillator)
P5sel = bit4 + bit5 + bit6;
While (1)
{
P2out ^ = 0x01;
Delay_us (10 );
}
}
Test results:
Entry Program of MSP430 (01) clock and delay