int adc_read_temps(en_adc_ref_vol_sel_t ref)
{
uint32_t result = 0;
uint16_t Crc_temps;
int32_t temps_turn;
Sysctrl_SetPeripheralGate(SysctrlPeripheralAdcBgr, TRUE);
Bgr_BgrEnable();
Bgr_TempSensorEnable();
Adc_Enable();
delay10us(2);
M0P_ADC->CR1_f.MODE = AdcSglMode;
M0P_ADC->CR0 |= (uint32_t)AdcMskInRefEnable |
(uint32_t)ref |
(uint32_t)AdcMskSampCycle6Clk |
(uint32_t)AdcMskClkDiv8 |
(uint32_t)AdcAiTsInput |
(uint32_t)AdcAlignRight |
(uint32_t)AdcMskBufEnable;
M0P_ADC->ICR_f.SGLIC = 0;
M0P_ADC->IFR_f.SGLIF = 0;
Adc_SGL_Start();
while(M0P_ADC->IFR_f.SGLIF != 1);
result = Adc_GetSglResult();
Bgr_TempSensorDisable();
Adc_SGL_Stop();
Adc_Disable();
Bgr_BgrDisable();
if(ref == AdcMskRefVolSelInBgr1p5)
{
Crc_temps = *(uint16_t *)0x00100C34 ;
temps_turn = result - Crc_temps;
LOG_Printf("@@@@@@result[%d]--------Crc_temps[%d]-------temps_turn[%d]\r\n",result,Crc_temps,temps_turn);
return 25 + 0.0795*1.5*(float)temps_turn;
}
else if(ref == AdcMskRefVolSelInBgr2p5)
{
Crc_temps = *(uint16_t *)0x00100C36;
temps_turn = result - Crc_temps;
LOG_Printf("@@@@@@result[%d]--------Crc_temps[%d]-------temps_turn[%d]\r\n",result,Crc_temps,temps_turn);
return 25 + 0.0795*2.5*(float )temps_turn;
}
return 0;
}
result 是ADC 模块测量温度传感器输出电压的结果,读取的数值10几 对比了文档 未发现原因,往大神指导
|