Part Number: MSP430FR2355
Tool/software: Code Composer Studio
Hello everyone,
I am currently using an MSP430FR2355 and am trying to take in an ECG signal using ADC Channel 1. The minimum voltage of the signal is roughly 200mV and the maximum voltage is 2.4V. I would like to take the adc values in continuously off this channel so that I can output them to an OLED display. However, when I run the code provided below, every value in the array is equal to 1. I am sure I am doing something wrong, however I am unable to figure it out. Any help would be greatly appreciated. Thanks in advance!
#include <msp430.h>
#include <stdio.h>
#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include "msp430fr2355.h"
void adc_init(void);
void adc_init(void){
P1SEL0 |= BIT1;
P1SEL1 |= BIT1;
ADCCTL0 &= (~ADCENC);
ADCCTL0 |= ADCSHT_0 + ADCON; // need to turn on ADCENC at end
ADCCTL1 |= ADCSSEL_0 + ADCCONSEQ_2;
ADCCTL2 |= ADCPDIV_2 + ADCRES_2 + ADCSR;
ADCMCTL0 |= ADCSREF_0 + ADCINCH_1;
ADCCTL0 |= ADCENC;
}
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
PM5CTL0 &= ~LOCKLPM5;
uint16_t ADC_temp[100] = {};
uint8_t i;
adc_init();
ADCCTL0 |= ADCENC + ADCSC;
for(i = 0; i < 100; i++){
while(!ADCBUSY);
ADC_temp[i] = ADCMEM0;
}
while(1);
return 0;
}