打印
[技术问答]

hc32l110的比较器怎么配置才能实现输入正端和输入负端电压是一致的?

[复制链接]
277|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
比较器配置代码:
void bspCMP_Init(void)
{
    stc_vc_general_config_t stcVcGeneralCfg;
    stc_vc_channel_config_t stcVcChannelCfg;
    //变量清0
    DDL_ZERO_STRUCT(stcVcGeneralCfg);
    DDL_ZERO_STRUCT(stcVcChannelCfg);
    Clk_SetPeripheralGate(ClkPeripheralVcLvd, TRUE);//开启VC时钟
    Clk_SetPeripheralGate(ClkPeripheralAdcBgr, TRUE);//配置ADC时钟
  
    M0P_BGR->CR_f.BGR_EN = 0x1u;//必须使能
    delay100us(1);
  
    Gpio_SetAnalog(3, 2, TRUE);
    Gpio_SetAnalog(3, 3, TRUE);
  
          genChannel = VcChannel1;//配置VC输入通道
    stcVcGeneralCfg.bDivEn = FALSE;//6位DAC不使能
    // stcVcGeneralCfg.enDivVref = VcDivVrefAdc;
    stcVcGeneralCfg.enDivVref = VcDivVrefAvcc;//VcDivVrefAvcc;//分压的参考电压为VCC
    stcVcGeneralCfg.u8DivVal = 0x3F;//分压值为1
    stcVcChannelCfg.enVcChannel = genChannel;//VC通道设置-----------------
    stcVcChannelCfg.enVcCmpDly = VcDelayoff;//迟滞配置
    stcVcChannelCfg.enVcBiasCurrent = VcBias20ua;//功耗选择
//    stcVcChannelCfg.enVcFilterTime = VcFilter7us;//输出滤波时间配置
    stcVcChannelCfg.enVcInPin_P = VcInPCh2;//P3.2
    stcVcChannelCfg.enVcInPin_N = VcInNCh3;//
    stcVcChannelCfg.enVcOutConfig = VcOutDisable;//输出配置寄存器
    stcVcChannelCfg.enVcIrqSel = VcIrqFall;
    stcVcChannelCfg.pfnAnalogCmpCb = VcIrqCallback;
    Vc_GeneralInit(&stcVcGeneralCfg);
    Vc_ChannelInit(genChannel, &stcVcChannelCfg);
   
    Vc_EnableFilter(genChannel);
          Vc_ConfigIrq(stcVcChannelCfg.enVcChannel, stcVcChannelCfg.enVcIrqSel);
          Vc_EnableIrq(stcVcChannelCfg.enVcChannel);
          Vc_EnableChannel(stcVcChannelCfg.enVcChannel);
}

模拟电压比较器经过配置后,正端的电压降到0V,而负端的电压保持与电源一致3.3V,如图。
file:///C:/Users/panpan/AppData/Local/Temp/ksohtml8248/wps1.jpg
若是正端的输入电压没有电源电压那么高,比较器不就一直输出低电平吗?

使用特权

评论回复
沙发
huangwentao|  楼主 | 2024-9-13 16:48 | 只看该作者

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

8

帖子

0

粉丝