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.

卡了三个月没搞定,CC2530电池电压采集,求教vv

Other Parts Discussed in Thread: CC2530, Z-STACK

CC2530采集电池电压,三个月无果,芯片手册都快翻烂了,找不出问题,求vv大神指教

采集方法:

使用芯片内部参考电压,采集15通道,也就是Vdd/3,然后算出Vdd

采集到的结果  一直是  40979

为了排除其他程序的干扰,只写了没有基于z-stack,直接祼跑,代码如下:

完整的工程在附件中,有兴趣的朋友请帮忙调试一下,万分感激!

void main(void)
{
        uint16 i=0;
        uint16 vdd, tmp;

        DISABLE_ALL_INTERRUPTS();
        CLKCONCMD &= ~0x40; //设置系统时钟源为32MHZ晶振
        while(CLKCONSTA & 0x40); //等待晶振稳定为32M
        CLKCONCMD &= ~0x47; //设置系统主时钟频率为32MHZ

        InitLed(); //设置LED灯相应的IO口
        uartInit();

        P0SEL |= (BV(1));
        APCFG |= (BV(1));

        ADCCON3 = 0x3F;
        ADCCON1 |= 0x30; //选择ADC的启动模式为手动


        while (1) {

                ADCCON1 |= 0x40; //启动AD转化

                while (!(ADCCON1 & 0x80));
                tmp = ADCL >> 4;
                vdd = ADCH;
                vdd *= 32;
                vdd += tmp;

                uart1_send_str("ADC:");
                uart1_send_int(vdd);
                uart1_send_str("\r\n");

                DelayMS(1000);
        }
}

ZStack-CC2530_ADC_Test.rar