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-MSPM0L2228: VREF and COMP Module

Part Number: LP-MSPM0L2228
Other Parts Discussed in Thread: MSPM0L2228, SYSCONFIG

Task: Evaluate a simple switch debouncing circuit as discussed in SCEA094 with MSPM0L2228's comparator module. 

image.png

image.png

Issue: While trying to use the MSPM0L2228 VREF and COMP module, I am not able to get the comparator to trigger at my configured threshold voltage of 1.5 volts. Instead it triggers around 20 mVolts. 

Test setup: Using a potentiometer to vary the voltage entering the COMP0_IN0- expecting to see LED toggle around 1.5 volts.

Below are my SysConfig settings for VREF and COMP:

image.png

image.png

Code snippets:

#include "ti_msp_dl_config.h"
#include  <stdio.h>

/*
 * DAC8 Reference Voltage in mV
 *  Adjust this value according to the external VREF voltage.
 */
#define COMP_INST_REF_VOLTAGE_mV (2500)
/*
 * DAC8 static output voltage in mV.
 *  Adjust output as needed.
 */
#define COMP_INST_DAC8_OUTPUT_VOLTAGE_mV (1500)

volatile static uint32_t onCount = 0, offCount = 0;

int main(void)
{
    uint32_t dacValue;

    SYSCFG_DL_init();

    /*
     * Set output voltage:
     *  DAC value (8-bits) = DesiredOutputVoltage x 255
     *                          -----------------------
     *                              ReferenceVoltage
     */
    dacValue =
        (COMP_INST_DAC8_OUTPUT_VOLTAGE_mV * 255) / COMP_INST_REF_VOLTAGE_mV;

    DL_COMP_setDACCode0(COMP_INST, dacValue);
    DL_COMP_enable(COMP_INST);

    NVIC_EnableIRQ(COMP_INST_INT_IRQN);

    /* Calling WFI after calling DL_SYSCTL_enableSleepOnExit will result in
     * only ISR code to be executed. This is done to showcase the device's
     * low power consumption when sleeping.
     */
    //DL_SYSCTL_enableSleepOnExit();
    
    while (1) {
        //__WFI();

        // Add a busy wait so the CPU stays in RUN mode
        for(volatile int i=0; i<10000000; i++);

        uint32_t status = DL_VREF_getStatus(VREF);

        printf("Status = %d | OnCount = %d | OffCount = %d\n", status, onCount, offCount);

    }
}

void GROUP1_IRQHandler(void)
{
    switch (DL_COMP_getPendingInterrupt(COMP_INST)) {
        case DL_COMP_IIDX_OUTPUT_EDGE:
            DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
            offCount++;
            break;
        case DL_COMP_IIDX_OUTPUT_EDGE_INV:
            DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
            onCount++;
            break;
        default:
            break;
    }
}

Questions:

  1. Whenever I select "Enable VREF as internal reference for COMP", the project fails to build. Why?
  2. Is there a way to test the VREF voltage through a pin or through the onboard ADC12?

Any guidance on the matter would be appreciated. 

  • Hi ***,
    1. Can you share the .syscfg and .c files here? i want to replicate the issue from my end and see if it may be a misconfiguration. Also, what is the error that shows? 

    2. The VREF can be monitored using an internal ADC channel (A0_28) which will need to be configured in the application code due to a bug that doesn't allow it to be configured in SYSCONFIG.

    Best Regards,

    Diego Abad

**Attention** This is a public forum