请问STM32内置温度传感器测温度公式是什么?

2019-07-14 14:31发布

从手册上看的是:
/* Temperature sensor calibration value address */
#define TEMP110_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7C2))
#define TEMP30_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7B8))
#define VDD_CALIB ((uint16_t) (330))
#define VDD_APPLI ((uint16_t) (300))
int32_t temperature; /* will contain the temperature in degree Celsius */
temperature = (((int32_t) ADC1->DR * VDD_APPLI / VDD_CALIB)
- (int32_t) *TEMP30_CAL_ADDR );
temperature = temperature * (int32_t)(110 - 30);
temperature = temperature / (int32_t)(*TEMP110_CAL_ADDR
- *TEMP30_CAL_ADDR);
temperature = temperature + 30;

用这个测出来是70多度
在网上搜的是图片上那样测出来是40多度,到底哪个可以用啊?


ADC初始化:
ADC_InitStructure.ADC_Resolution=ADC_Resolution_12b;
        ADC_InitStructure.ADC_ContinuousConvMode=ENABLE;
        ADC_InitStructure.ADC_ExternalTrigConvEdge=ADC_ExternalTrigConvEdge_None;
        ADC_InitStructure.ADC_ExternalTrigConv=DISABLE;
        ADC_InitStructure.ADC_DataAlign=ADC_DataAlign_Right;
        ADC_InitStructure.ADC_ScanDirection=ADC_ScanDirection_Upward;
        ADC_Init(ADC1, &ADC_InitStructure);
        ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);
               
  ADC_Cmd(ADC1, ENABLE);
        ADC_TempSensorCmd(ENABLE);
  ADC_ChannelConfig(ADC1, ADC_Channel_16, ADC_SampleTime_239_5Cycles);
        ADC_StartOfConversion(ADC1);



友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。