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.

z-stack ADC测量偏差

Other Parts Discussed in Thread: CC2530

HalAdcInit();
APCFG |= 0x01;//设置为模拟io
P0SEL |= 0x01;// 0为普通io,1为外设io?
P0DIR &= 0xFE;
//P0INP |= 0x01;//P0.0设置为三态
MicroWait (1000);

Data_ADC = HalAdcRead (HAL_ADC_CHANNEL_0, HAL_ADC_RESOLUTION_7);

以上是我测试cc2530 的ADC的程序;Data_ADC的值为40,测量P0_0引脚电压为1.116v;

40/64  * 1.15 = 0.71875

纯在较大偏差  是我计算错了呢?

求解!!

  • 应该是,没有HAL_ADC_RESOLUTION_7

    #define HAL_ADC_RESOLUTION_8 0x01
    #define HAL_ADC_RESOLUTION_10 0x02
    #define HAL_ADC_RESOLUTION_12 0x03
    #define HAL_ADC_RESOLUTION_14 0x04

  • 在cc2530 EB的工程里有,如下;

    但是我也用过其他的,比如HAL_ADC_RESOLUTION_12,也是存在一样的问题;

    #include "hal_board.h"

    /**************************************************************************************************
    * CONSTANTS
    **************************************************************************************************/

    /* Resolution */
    #define HAL_ADC_RESOLUTION_7 0x00
    #define HAL_ADC_RESOLUTION_9 0x01
    #define HAL_ADC_RESOLUTION_10 0x02
    #define HAL_ADC_RESOLUTION_12 0x03

    /* Channels */
    #define HAL_ADC_CHANNEL_0 0x00
    #define HAL_ADC_CHANNEL_1 0x01
    #define HAL_ADC_CHANNEL_2 0x02
    #define HAL_ADC_CHANNEL_3 0x03
    #define HAL_ADC_CHANNEL_4 0x04
    #define HAL_ADC_CHANNEL_5 0x05
    #define HAL_ADC_CHANNEL_6 0x06
    #define HAL_ADC_CHANNEL_7 0x07

  • 00: 64 decimation rate (7 bits ENOB setting)
    01: 128 decimation rate (9 bits ENOB setting)
    10: 256 decimation rate (10 bits ENOB setting)
    11: 512 decimation rate (12 bits ENOB setting

    有效数字的以为是否正确?