本帖最后由 t9080350 于 2022-4-14 15:22 编辑
请教。HC32L130J8TA ADC内部温度传感器 读取ADC失败。读出来的数值总是4095,试过换通道到1/2 VREF也是一样的结果,不知道是卡在哪里了,请各位高手指点,感谢!!!
代码如下:
void adc_config()
{
stc_adc_cfg_t stc_adc_cfg;
DDL_ZERO_STRUCT(stc_adc_cfg);
Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE);
Bgr_BgrEnable();
Bgr_TempSensorEnable();
stc_adc_cfg.enAdcMode = AdcSglMode;
stc_adc_cfg.enAdcClkDiv = AdcMskClkDiv8;
stc_adc_cfg.enAdcSampCycleSel = AdcMskSampCycle12Clk;
stc_adc_cfg.enAdcRefVolSel = AdcMskRefVolSelInBgr2p5;
stc_adc_cfg.enAdcOpBuf = AdcMskBufEnable;
stc_adc_cfg.enInRef = AdcMskInRefEnable;
stc_adc_cfg.enAdcAlign = AdcAlignRight;
Adc_Init(&stc_adc_cfg);
Adc_CfgSglChannel(AdcAiTsInput);
}
uint32_t adc_value;
int32_t main(void)
{
uart0_config();
adc_config();
while(1)
{
M0P_ADC->SGLSTART = 1u; //启动单次转换采样
adc_value = M0P_ADC->RESULT; // 读取ADC采样电压
M0P_ADC->SGLSTART = 0u; //ADC 单次转换停止
delay1ms(1000);
}
}
寄存器状态:
|