This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CCS:温度的ADC读数。

Guru**** 2534260 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/577276/ccs-adc-reading-for-temperature

工具/软件:Code Composer Studio

您好,

下面的代码用于查找温度。实际上,我可以精确地读取某些时间的温度,而稍后对于相同的代码数据则不正确。因此,请建议一致的答案或数据

/* DriverLib包括*/
#include "LibG2_main.h"
挥发性浮点温度;
挥发性浮子温度;
int64_t状态;
//UINT32_t cal30,cal85;
//#定义cal30 *((unsigned int *) 0x0.201万DC)//温度传感器校准-30 C
//有关TLV表内存映射,请参见设备数据表
//#定义cal85 *((unsigned int *) 0x0.201万E0)//温度传感器校准
易失性内部32_t临时;
int32_t cal30,cal85;
内部主(无效)

int q;
/*正在停止WDT */
WDT_A_HoldTimer();

/*启用FPU并启用堆栈(用于ISR)*/
//FPU_enableModule();
//FPU_enableLazyStacking();

ref_a_setReferenceVoltage (REF_A_VREF2_5V);
ref_a_enableReferenceVoltage();
ref_a_enableTempSensor();


/*在温度传感器已布设的情况下初始化ADC (MCLK/1/1)*/
ADC14_enableModule();
ADC14_INITModule (ADC_CLOCKSOURCE_SMCLK,ADC_PREDIVIDER_1,ADC_DIVIDER_1,
ADC_TEMPSENSEMAP);

/*重复配置ADC内存(ADC_MEM0 A22 (温度传感器)
*模式)。
*/
ADC14_configureSingleSampleMode (ADC_MEM1,TRUE);
ADC14_configureConversionMemory(ADC_MEM1, ADC_VREFPOS_INTBUF_VREFNEG_VSS,
ADC_INPUT_A22,FALSE);

/*为TBD */配置采样/保持时间
ADC14_setSampleHoldTime (ADC_PULSE_WIDES_192,ADC_PULSE_WIDES_192);

/*在自动迭代模式下启用采样计时器并中断*/
ADC14_enableSampleTimer(ADC_AUTOMATICATE_IREDATE);
ADC14_enableInterrupt (ADC_INT1);

/*将参考电压设置为2.5 并启用温度传感器*/

/*启用中断*/
//Interrupt_enableInterrupt (INT_ADC14);
//Interrupt_enableMaster();

/*触发样本开始*/
ADC14_enableConversion();
ADC14_toggleConversionTrigger();

/*进入睡眠状态*/
同时(1)

状态= ADC14_getEnabledInterruptStatus();
ADC14_clearInterruptFlag (状态);

IF (状态和ADC_INT1)

cal30 = sysctl_getTempCalibrationConstant (sysctl_2_5V_REF,
sysctl_30_degrees_C);
cal85 = sysctl_getTempCalibrationConstant (sysctl_2_5V_REF,
sysctl_85_degrees_C);

tempC =(float)(((Int32_t) ADC14_getResult (ADC_MEM1)- cal30)*(85 - 30))
/(cal85 - cal30)+ 30.0f;

tempF = tempC * 9.0f / 5.0f + 32.0f;
}
}
}