This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

我的AD采样计算心律程序,进不了中断,求找错, 我每次采的2000个点样本内找出能判断一个R波的条件,并记录3个周期内采样点各数,然后算心律

Other Parts Discussed in Thread: MSP430F5529

#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;

新建 Microsoft Word 文档 (3).doc