1年10个月前IP:广东
940488
2楼

/* ADC internal channels related definitions */

/* Internal voltage reference VrefInt */

#define VREFINT_CAL_ADDR                   ((uint16_t*) (0x1FFF7A2AU)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */

#define VREFINT_CAL_VREF                   ( 3300UL)                    /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */

/* Temperature sensor */

#define TEMPSENSOR_CAL1_ADDR               ((uint16_t*) (0x1FFF7A2CU)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32F4, temperature sensor ADC raw data acquired at temperature  30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */

#define TEMPSENSOR_CAL2_ADDR               ((uint16_t*) (0x1FFF7A2EU)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32F4, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */

#define TEMPSENSOR_CAL1_TEMP               (( int32_t)   30)           /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */

#define TEMPSENSOR_CAL2_TEMP               (( int32_t)  110)           /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */

#define TEMPSENSOR_CAL_VREFANALOG          ( 3300UL)                    /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */


float adc_mcutemp(uint16_t adcval)

{

  float dtemp = TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP;

  float dcal = TEMPSENSOR_CAL2_ADDR - TEMPSENSOR_CAL1_ADDR;

  float calv = *TEMPSENSOR_CAL1_ADDR;

  float calt = TEMPSENSOR_CAL1_TEMP;

  return (adcval - calv) * dtemp / dcal + calt;

}

从arduino ststm32抠出来的,供参考

+1
科创币
全桥整流
2024/12/19
谢谢
评论
文号 / 940488

万流景仰
名片发私信
学术分 12
总主题 379 帖总回复 8283 楼拥有证书:进士 学者 机友
注册于 2008/10/11 20:04:00最后登录 2026/10/12 22:44:46
主体类型:个人
所属领域:无
认证方式:手机号
IP归属地:0

个人简介

Cubesat

笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的