RM0444 第 5 版第 377 页说
• TS_CAL2 是在 TS_CAL2_TEMP 获取的温度传感器校准值
(有关 TS_CAL2 值,请参阅数据表)
• TS_CAL1 是在 TS_CAL1_TEMP 获取的温度传感器校准值
(请参阅数据表了解 TS_CAL1 值)
• TS_DATA 为ADC 转换后的实际温度传感器输出值
有关 TS_CAL1 和
TS_CAL2 校准点。
所以我需要找到 TS_CAL1、TS_CAL2、TS_CAL2_TEMP 和 TS_CAL1_TEMP
我转到 DS12992 Rev 2 第 24 页第 3.14.1 段:
温度传感器 (TS) 产生随温度线性变化的电压 V TS 。
温度传感器在内部连接到 ADC 输入以将传感器转换
输出电压转换成数字值。
传感器提供良好的线性度,但必须对其进行校准以获得良好的整体
温度测量的准确性。由于温度传感器的偏移可能
由于过程变化而因零件而异,未经校准的内部温度传感器
仅适用于相对温度测量。
为了提高温度传感器的精度,每个部分都是单独的工厂-
由 ST 校准。生成的校准数据存储在部件的工程字节中,
以只读模式访问。
表 5. 温度传感器校准值
校准值名称 描述 内存地址
TS_CAL1
TS ADC 原始数据在
温度为 30 °C (± 5 °C),
V DDA = V REF+ = 3.0 V (± 10 mV)
0x1FFF 75A8 - 0x1FFF 75A9
TS_CAL2
TS ADC 原始数据在
温度为 130 °C (± 5 °C),
V DDA = V REF+ = 3.0 V (± 10 mV)
0x1FFF 75CA - 0x1FFF 75CB
所以文档中给出了我需要的 4 个值中的两个。
所以我去CODE。
I Search for TS_CAL1, TS_CAL2, TS_CAL2_TEMP, TSCAL1_TEMP 除了在根据其数据计算温度的宏的注释中外,没有找到。在
STM32g0xx_ll_adc.h中找到
- /**
- * @brief Helper macro to calculate the temperature (unit: degree Celsius)
- * from ADC conversion data of internal temperature sensor.
- * @note Computation is using temperature sensor calibration values
- * stored in system memory for each device during production.
- * @note Calculation formula:
- * Temperature = ((TS_ADC_DATA - TS_CAL1)
- * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
- * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
- * with TS_ADC_DATA = temperature sensor raw data measured by ADC
- * Avg_Slope = (TS_CAL2 - TS_CAL1)
- * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
- * TS_CAL1 = equivalent TS_ADC_DATA at temperature
- * TEMP_DEGC_CAL1 (calibrated in factory)
- * TS_CAL2 = equivalent TS_ADC_DATA at temperature
- * TEMP_DEGC_CAL2 (calibrated in factory)
- * Caution: Calculation relevancy under reserve that calibration
- * parameters are correct (address and data).
- * To calculate temperature using temperature sensor
- * datasheet typical values (generic values less, therefore
- * less accurate than calibrated values),
- * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
- * @note As calculation input, the analog reference voltage (Vref+) must be
- * defined as it impacts the ADC LSB equivalent voltage.
- * @note Analog reference voltage (Vref+) must be either known from
- * user board environment or can be calculated using ADC measurement
- * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
- * @note On this STM32 series, calibration data of temperature sensor
- * corresponds to a resolution of 12 bits,
- * this is the recommended ADC resolution to convert voltage of
- * temperature sensor.
- * Otherwise, this macro performs the processing to scale
- * ADC conversion data to 12 bits.
- * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
- * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
- * temperature sensor (unit: digital value).
- * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
- * sensor voltage has been measured.
- * This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @retval Temperature (unit: degree Celsius)
- * In case or error, value LL_ADC_TEMPERATURE_CALC_ERROR is returned (inconsistent temperature value)
- */
- #define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,
- __TEMPSENSOR_ADC_DATA__,
- __ADC_RESOLUTION__)
- ((((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) != 0) ?
- (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__),
- (__ADC_RESOLUTION__),
- LL_ADC_RESOLUTION_12B)
- * (__VREFANALOG_VOLTAGE__))
- / TEMPSENSOR_CAL_VREFANALOG)
- - (int32_t) *TEMPSENSOR_CAL1_ADDR)
- ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP)
- ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR)
- ) + TEMPSENSOR_CAL1_TEMP
- )
- :
- ((int32_t)LL_ADC_TEMPERATURE_CALC_ERROR)
- )
所以这里看起来他们在等式中使用了 TS_CAL1_TEMP,但在 TS_CAL1 的描述中将其称为 TEMP_DEGC_CAL1
他们对 TS_CAL2_TEMP 做同样的事情,称之为 TEMP_DEGC_CAL2
不幸的是我找不到
TEMP_DEGC_CAL1
TEMP_DEGC_CAL2
在代码中的任意位置定义。
那么我们应该怎么做呢?
0