Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Help with ECG program

$
0
0

I'm still a beginner in programming and I really need your help. I'm using a msp430f2274 for my project: to convert an ECG signal to digital one using ADC on msp430 and view the data as a graph in CCS and I'm not really sure how to do the graph. Below is my code :

 

#include  <msp430.h>
// Global variables
unsigned int ADC_value=0;
 
// Function prototypes
void ConfigureAdc(void);
 
void main(void)
{
  {
     WDTCTL = WDTPW + WDTHOLD; // Stop WDT
     BCSCTL1 = CALBC1_1MHZ; // Set range   DCOCTL = CALDCO_1MHZ;
     BCSCTL2 &= ~(DIVS_3); // SMCLK = DCO = 1MHz
     P2SEL |= BIT4; // ADC input pin P2.4
     ConfigureAdc(); // ADC set-up function call
     __enable_interrupt(); // Enable interrupts.
 
     while(1)
     {
           __delay_cycles(1000); // Wait for ADC Ref to settle
           ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
           __bis_SR_register(CPUOFF + GIE); // Low Power Mode 0 with interrupts enabled
           ADC_value = ADC10MEM; // Assigns the value held in ADC10MEM to the integer called ADC_value
 
     }
 
  }
}
 
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR (void)
{
     __bic_SR_register_on_exit(CPUOFF);        // Return to active mode }
}
 
// Function containing ADC set-up
void ConfigureAdc(void)
{
 
   ADC10CTL1 = INCH_4 + ADC10DIV_3 ;         // Channel 4, ADC10CLK/3
   ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE;  // Vcc & Vss as reference, Sample and hold for 64 Clock cycles, ADC on,      ADC interrupt enable
   ADC10AE0 |= BIT4;                         // ADC input enable P2.4
}

Viewing all articles
Browse latest Browse all 2077

Trending Articles