基于MSP430单片机的电子式互感器采集器的程序
基于MSP430单片机的电子式互感器采集器的程序.zip
(101.07 KB)
#include <msp430x20x3.h>
volatile unsigned short counter = 0;
volatile unsigned short delay = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0xFF; // P1.0 output
DCOCTL = 0xE0; // set DCO -> 16MHz
BCSCTL1 = 0x0F;
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 2000;
TACTL = TASSEL_2 + MC_1; // SMCLK, upmode
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt // P1.1 = 1
}
// Timer A0 interrupt service routine
#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A (void)
{
counter++;
if(counter >= 10000)
{
counter = 0;
}
else if(counter < 1000)
{
P1OUT = 0xFF;
}
else
{
P1OUT = 0x00;
}
}
|