#include <msp430f5529.h>
volatile unsigned int i; unsigned int m;
unsigned int data[2000] ; int t=0 ;
unsigned int pulseperiod ;
int main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop watchdog timer
P3SEL = BIT4 + BIT3 ; // P3.4 = RXD, P3.3=TXD
// P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
P6SEL |= 0x01; // Enable A/D channel A0
REFCTL0 &= ~REFMSTR; // Reset REFMSTR to hand over control to
// ADC12_A ref control registers
//***************************************************************
ADC12CTL0 = ADC12ON+ADC12SHT0_4+ADC12REFON+ADC12REF2_5V;
// Turn on ADC12, Sampling time
// On Reference Generator and set to 2.5V
ADC12CTL1 = ADC12CONSEQ_0 ; //singer chance duoci
ADC12CTL1 = ADC12SHP; // Use sampling timer
ADC12MCTL0 = ADC12SREF_1; // Vr+=Vref+ and Vr-=AVss
ADC12IE = 0X01;
for ( i=0; i<30; i++); // Delay for reference start-up
ADC12CTL0 |= ADC12ENC; // Enable conversions
_EINT(); //open all interrupt
ADC12CTL0 |= ADC12SC;
//*****************************************************
//心律计算
while(t==2000)
{
int n , beat =0 , con[3] , p=0 , heartrate;