TI中文支持网
TI专业的中文技术问题搜集分享网站

cc2530F256工作温度问题

现在用cc2530F256开发产品发现一个问题,就是通过下面函数获得芯片的工作电压,但是发现,随着温度的降低,监测的电压也随着变小,实际的供电电压是没有改变的,

static uint8 readVoltage(void)
{
uint16 value;

// Clear ADC interrupt flag ADCIF = 0;

ADCCON3 = (0x00 | 0x10 | 0x0f);

// Wait for the conversion to finish while ( !ADCIF );

// Get the result
value = ADCL;
value |= ((uint16) ADCH) << 8;

// value now contains measurement of Vdd/3
// 0 indicates 0V and 32767 indicates 1.25V
// voltage = (value*3*1.25)/32767 volts
// we will multiply by this by 10 to allow units of 0.1 volts
value = value >> 6; // divide first by 2^6
value = (uint16)(value * 34.5);
value = value >> 9; // …and later by 2^9…to prevent overflow during multiplication

return value;
}

Susan Yang:

您现在是使用电池供电的? 建议尝试以下操作

定义

#define HAL_ADC_EOC 0x80 // End of Conversion bit#define HAL_ADC_START 0x40 // Starts Conversion#define HAL_ADC_RESOLUTION_8 0x01#define HAL_ADC_RESOLUTION_10 0x02#define HAL_ADC_RESOLUTION_12 0x03#define HAL_ADC_RESOLUTION_14 0x04#define HAL_ADC_CHN_VDD3 0x0f    // VDD/3#define HAL_ADC_REF_125V 0x00    // Internal Reference (1.15V for CC2530)

 
调用函数 uint16 sampledVoltage = adcRead( HAL_ADC_CHN_VDD3, HAL_ADC_RESOLUTION_12 ); 
 使用 adcRead()

uint16 adcRead (uint8 channel, uint8 resolution)

{

int16  reading = 0;

uint8   i, resbits;

uint8  adcChannel = 1;

if (channel < 8)

for (i=0; i < channel; i++)

adcChannel <<= 1;

/* Enable channel */

ADCCFG |= adcChannel;

/* Convert resolution to decimation rate */

switch (resolution) {

case HAL_ADC_RESOLUTION_8:

resbits = HAL_ADC_DEC_064;

break;

case HAL_ADC_RESOLUTION_10:

resbits = HAL_ADC_DEC_128;

break;

case HAL_ADC_RESOLUTION_12:

resbits = HAL_ADC_DEC_256;

break;

case HAL_ADC_RESOLUTION_14:

default:

resbits = HAL_ADC_DEC_512;

break;

}

/* writing to this register starts the extra conversion */

ADCCON3 = channel | resbits | HAL_ADC_REF_125V;

/* Wait for the conversion to be done */

while (!(ADCCON1 & HAL_ADC_EOC));

/* Disable channel after done conversion */

ADCCFG &= (adcChannel ^ 0xFF);

/* Read the result */

reading = (int16) (ADCL);

reading |= (int16) (ADCH << 8);

/* Treat small negative as 0 */

if (reading < 0)

reading = 0;

switch (resolution) {

case HAL_ADC_RESOLUTION_8:

reading >>= 8;

break;

case HAL_ADC_RESOLUTION_10:

reading >>= 6;

break;

case HAL_ADC_RESOLUTION_12:

reading >>= 4;

break;

case HAL_ADC_RESOLUTION_14:

default:

reading >>= 2;

break;

}

return ((uint16)reading);

}

shaojun jiang:

回复 Susan Yang:

你好,测试了,还是不行,-20度,电压偏差有0.2v左右,常温下读值正确,温度低了就有偏差了

user4484888:

回复 shaojun jiang:

你好,你的问题解决了吗?

user4484888:

回复 Susan Yang:

你好 在吗
我也遇到类似低温的时候,产品工作不正常。

YiKai Chen:

回复 user4484888:

不同溫度條件下的ADC讀值需要自行校正

Susan Yang:

回复 user4484888:

请您将问题详细描述后重新发帖,请不要跟踪旧贴,谢谢

赞(0)
未经允许不得转载:TI中文支持网 » cc2530F256工作温度问题
分享到: 更多 (0)