Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Interfacing heart beat sensor with the msp430g2253 - Use the code below to calculate heart beats per minute - using any method you want. Please

Interfacing heart beat sensor with the msp430g2253 - Use the code below to calculate heart beats per minute - using any method you want. Please explain too. Thanks

(The code gets 10 values from the sensor and averages them). I'd like to calculate heart beats per minute.

#include "msp430g2253.h" // Variables int adc[50] = {0}; //Sets up an array of 10 integers and zero's the values int avg_adc = 0; // Function prototypes void adc_Setup(); void adc_Sam10(); void main() { WDTCTL = WDTPW + WDTHOLD; // Stop WDT adc_Setup(); // Fucntion call for adc_setup while(1) { long adctot = 0; adc_Sam10(); // Function call for adc_samp // Add all the sampled data and divide by 10 to find average int i = 0; for(i = 0; i <= 49; i++){ adctot = adctot + adc[i]; } avg_adc = adctot/50; } } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR) } // ADC set-up function void adc_Setup() { ADC10CTL1 = CONSEQ_2 + INCH_0; // Repeat single channel, A0 ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; // Sample & Hold Time + ADC10 ON + Interrupt Enable ADC10DTC1 = 0x32; // 1000 conversions ADC10AE0 |= 0x01; // P1.0 ADC option select } // ADC sample conversion function void adc_Sam10() { ADC10CTL0 &= ~ENC; // Disable Conversion while (ADC10CTL1 & BUSY); // Wait if ADC10 busy ADC10SA = (int)adc; // Transfers data to next array (DTC auto increments address) ADC10CTL0 |= ENC + ADC10SC; // Enable Conversion and conversion start __bis_SR_register(CPUOFF + GIE);// Low Power Mode 0, ADC10_ISR } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Classify delivery styles by type.

Answered: 1 week ago