Other Parts Discussed in Thread: MSPM0L2228, SYSCONFIG
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号: LP-MSPM0L2228
主题: MSPM0L2228、 SysConfig 中讨论的其他器件
任务:评估 SCEA094 与 MSPM0L2228 比较器模块中所述的简单开关去抖电路。


问题:在尝试使用 MSPM0L2228 VREF 和 COMP 模块时、我无法让比较器在配置的 1.5 伏阈值电压下触发。 而是在 20 毫伏左右触发。
测试设置:使用电位器改变进入 COMP0_IN0-的电压、预计 LED 会在 1.5 伏左右切换。
以下是 VREF 和 COMP 的 SysConfig 设置:


代码片段:
#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;
}
}
问题:
- 每当我选择“Enable VREF as internal reference for COMP“时、工程就无法编译。 为什么?
- 是否有办法通过引脚或板载 ADC12 测试 VREF 电压?
希望就此事项提供任何指导。