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 和 COMP 模块

Guru**** 3036140 points

Other Parts Discussed in Thread: MSPM0L2228, SYSCONFIG

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1666673/lp-mspm0l2228-vref-and-comp-module

器件型号: LP-MSPM0L2228
主题: MSPM0L2228、 SysConfig 中讨论的其他器件

任务:评估 SCEA094 与 MSPM0L2228 比较器模块中所述的简单开关去抖电路。  

image.png

image.png

问题:在尝试使用 MSPM0L2228 VREF 和 COMP 模块时、我无法让比较器在配置的 1.5 伏阈值电压下触发。 而是在 20 毫伏左右触发。  

测试设置:使用电位器改变进入 COMP0_IN0-的电压、预计 LED 会在 1.5 伏左右切换。

以下是 VREF 和 COMP 的 SysConfig 设置:

image.png

image.png

代码片段:

#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;
    }
}

问题:

  1. 每当我选择“Enable VREF as internal reference for COMP“时、工程就无法编译。 为什么?
  2. 是否有办法通过引脚或板载 ADC12 测试 VREF 电压?

希望就此事项提供任何指导。  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好***、
    1.可以在这里共享.syscfg 和.c 文件吗? 我想从我的身边复制问题、看看它是否可能是错误配置。 另外、显示的误差是什么?  

    2.可以使用内部 ADC 通道 (A0_28) 监控 VREF、由于一个错误不允许在 SysConfig 中配置该错误、因此需要在应用程序代码中配置该通道。

    此致、

    Diego Abad