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.

LP-MSPM0G3507: Issues with ADC Triggering via Comparator (COMP) in Postgraduate Project

Part Number: LP-MSPM0G3507

Tool/software:

Hello everyone,

I am working on a project for my postgraduate studies and I've encountered an issue with part of the code. The goal is to trigger a 12-bit ADC through a comparator (COMP) using an external pin. The values captured by the ADC should be stored in an array and later sent to a CSV file.

However, I am having trouble with triggering the ADC, both via interruption and 'event'. The ADC only executes once and then the entire code stops. Below is the code I am using:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const ADC12 = scripting.addModule("/ti/driverlib/ADC12", {}, false);
const ADC121 = ADC12.addInstance();
const Board = scripting.addModule("/ti/driverlib/Board");
const COMP = scripting.addModule("/ti/driverlib/COMP", {}, false);
const COMP1 = COMP.addInstance();
const GPIO = scripting.addModule("/ti/driverlib/GPIO", {}, false);
const GPIO1 = GPIO.addInstance();
const GPIO2 = GPIO.addInstance();
const GPIO3 = GPIO.addInstance();
const GPIO4 = GPIO.addInstance();
const GPIO5 = GPIO.addInstance();
const OPA = scripting.addModule("/ti/driverlib/OPA", {}, false);
const OPA1 = OPA.addInstance();
const SYSCTL = scripting.addModule("/ti/driverlib/SYSCTL");
const VREF = scripting.addModule("/ti/driverlib/VREF");
/**
* Write custom configuration values to the imported modules.
*/
const divider9 = system.clockTree["UDIV"];
divider9.divideValue = 2;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include "ti/driverlib/dl_adc12.h"
#include "ti/driverlib/dl_gpio.h"
#include "ti_msp_dl_config.h"
#include "sys/_stdint.h"
#include "ti/driverlib/m0p/dl_core.h"
#define COMP_INST_REF_VOLTAGE_mV (3300)
#define COMP_INST_DAC8_OUTPUT_VOLTAGE_mV (50)
const uint16_t ADC_RESOLUTION = 12;
const uint16_t ARRAY_SIZE = 0x01 << ADC_RESOLUTION;
volatile bool gCheckADC = false;
volatile bool start = false;
volatile uint16_t gADCResult = 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Issue Faced:

  • The ADC is triggered only once and does not continue as expected.

If anyone could provide guidance or support on how to resolve this issue, I would greatly appreciate it.

Thank you in advance for your help!

  • Hi Diego,

    When you stop the program with a debugger, where are you in the code? Place a breakpoint at 134 you can catch after the first read and check to make sure the ADC configurations is as expected.

    Regards,
    Luke

  • Hello Lucas,

    before starting before starting

    The program gets stuck (in a loop) at line 133, waiting for the 'start' value to return to '1'.
     before the first pass through while

    The first time it is triggered and it enters the functions "readADC" and "recordADC" normally.

    When it returns to make a second pass through the 'while' loop, the value of 'start' is '0' and does not return to '1'.

     second passed by while

    Could there be something wrong that I did in the comparator configuration?

    Attached is an image of the comparator configuration screen in CCS Theia.

    Thank you very much for the help.

  • Hi Diego,

    The comparator portion doesn't look wrong to me at first glance. What's your input signal? You have a trigger on the rising or falling edge, so what I would expect is anytime you cross the 50mV mark (based on line 13) you should get a trigger on your comparator. You can place a breakpoint in your COMP ISR and then switch your COMPIN+ signal to verify you are getting a trigger on the rising and falling edges.

    Regards,
    Luke