微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI Zigbee设计交流 > cc2530F256工作温度问题

cc2530F256工作温度问题

时间:10-02 整理:3721RD 点击:

现在用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;

}

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

  1. 定义

    #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)

     
  2. 调用函数 uint16 sampledVoltage = adcRead( HAL_ADC_CHN_VDD3, HAL_ADC_RESOLUTION_12 );
     
  3.  使用 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);

}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top