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.

MSP430FR5994: Implementing two ADC inputs

Part Number: MSP430FR5994

Hi. I'm trying to implement an input where I have two ADC inputs from two different voltage sources. I'm starting out by working with the basic ADC code with one input, but I am unable to find the documentation or sample code that lets me conduct a dual ADC input.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <msp430.h>
#include <stdio.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// GPIO Setup
P1OUT &= ~BIT0; // Clear LED to start
P1DIR |= BIT0; // Set P1.0/LED to output
P1SEL1 |= BIT2 | BIT3 ; // Configure P1.2 and P1.3 for ADC input (See p369, p88 of specific for pin config details.)
P1SEL0 |= BIT2 | BIT3 ; // There are two Pin Select bits (p88_s)
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings (p92)
PM5CTL0 &= ~LOCKLPM5;
// Configure ADC12
ADC12CTL0 = ADC12SHT0_2 | ADC12ON; // Sampling time, S&H=16, ADC12 on [p893, CTL0 = control 0, SHT0_2 = sample & hold time, knowledge of register value from p88_s]
ADC12CTL1 = ADC12SHP; // Use sampling timer [p895, Sampler uses sampling timer (not sure what that is yet)]
ADC12CTL2 |= ADC12RES_2; // 12-bit conversion results [p897, RES means resolution, _2 means 12 bits]
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

My code so far. My ultimate objective is to collect the ADC information from these two voltage sources, subtract them, then collect the ADC information from the next sampling time (I'm planning a sampling time of 32Hz), subtract them two, and then compare these two ADC information. I am doing this to compare two demodulated FM signals, if that helps. Please let me know if more information is needed.

  • I have found a solution:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include <msp430.h>
    #include <stdio.h>
    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop WDT
    // GPIO Setup
    P1OUT &= ~BIT0; // Clear LED to start
    P1DIR |= BIT0; // Set P1.0/LED to output
    P1SEL1 |= BIT2 | BIT3 ; // Configure P1.2 and P1.3 for ADC input (See p369, p88 of specific for pin config details.)
    P1SEL0 |= BIT2 | BIT3 ; // There are two Pin Select bits (p88_s)
    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings (p92)
    PM5CTL0 &= ~LOCKLPM5;
    printf("17\n");
    // Configure ADC12
    ADC12CTL0 = ADC12SHT0_2 | ADC12ON; // Sampling time, S&H=16, ADC12 on [p893, CTL0 = control 0, SHT0_2 = sample & hold time, knowledge of register value from p88_s]
    ADC12CTL1 = ADC12SHP | ADC12CONSEQ_1; // Use sampling timer [p895, Sampler uses sampling timer (not sure what that is yet)]
    ADC12CTL2 |= ADC12RES_2; // 12-bit conversion results [p897, RES means resolution, _2 means 12 bits]
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I needed to set the CONSEQ bits to 01 which change the mode of operation to sequence of channel mode (explained in p879), and set the ADC12EOS bit to 1 at the MEM3 interrupt (line 79, explained in p900). This bit needs to be toggled off every time the code is reactivated or the sequence will stop.

**Attention** This is a public forum