最近刚拿到MSP432,在跑ADC14部分的程序时,发现内部温度传感器的程序有问题,数据一直为0。
我分别跑了2个例程,1个是寄存器操作的,另外1个是驱动库的,存在的问题一样:读取30度和85度的校正值有问题。
1.寄存器操作定义了:
#define CALADC_15V_30C *((unsigned int *)0x1A1A) // Temperature Sensor Calibration-30 C
// See device datasheet for TLV table memory mapping
#define CALADC_15V_85C *((unsigned int *)0x1A1C) // Temperature Sensor Calibration-85 C
我看不懂0x1A1A 和0x1A1C这个指针到底是指向哪里?datasheet也没有!
2.驱动库:
cal30=SysCtl_getTempCalibrationConstant(SYSCTL_2_5V_REF,SYSCTL_30_DEGREES_C);
cal85=SysCtl_getTempCalibrationConstant(SYSCTL_2_5V_REF,SYSCTL_85_DEGREES_C);
tempC=(float)(((uint32_t)ADC14_getResult(ADC_MEM0)-cal30)*(85-30))/(cal85-cal30)+30.0f;
我看了驱动库手册,SysCtl_getTempCalibrationConstant()的定义,它返回none,这里这样引用该函数,显然有问题!TI能否提供详细一点的datasheet!这2个校正值在TLV里,但我没有在datasheet找到。
Retrieves the calibration constant of the temperature sensor to be used //! in temperature calculation. //! //! \param refVoltage Reference voltage being used. //! //! The \e resetType parameter must be only one of the following values: //!- \b SYSCTL_1_2V_REF //!- \b SYSCTL_1_45V_REF //!- \b SYSCTL_2_5V_REF //! //! \param temperature is the calibration temperature that the user wants to be //!returned. //! //! The \e temperature parameter must be only one of the following values: //!- \b SYSCTL_30_DEGREES_C //!- \b SYSCTL_85_DEGREES_C //! //! \return None.
灰小子:
MSP432P4xx Family Technical Reference Manual里有对TLV的介绍,包括Typical Temperature Sensor Transfer Function