SYD8801 ADC使用说明【校准】

SYD8801是一款低功耗高性能蓝牙低功耗SOC,集成了高性能2.4GHz射频收发机、32位ARM Cortex-M0处理器、128kB Flash存储器、以及丰富的数字接口。SYD8801片上集成了Balun无需阻抗匹配网络、高效率DCDC降压转换器,适合用于可穿戴、物联网设备等。具体可咨询:http://www.syd-tek.com/

SYD8801 ADC使用说明

先来看看官方说明:

6.5 General Purpose ADC
The SYD8801 integrates a low power 10-bit general purpose Analog-to-Digital Converter (GPADC) with 32kHz sampling
rate. For each one shot measurement, it takes 150us for data acquisition. It can operate as a 4-channel ADC by switching
the GPADC input. Two channels for internal Battery Voltage detection (VBAT3V, VBAT1V), while the other two are configured
to monitor GPIO0 or GPIO1. For better accuracy, internal reference voltage calibration is preferred. Sensing applications
as battery monitoring, temperature resister, analog signal sampling could be applied with this GPADC.


注意:并不是所有的通道都是用来采集外部ADC的,第一第二个通道用来做内部电压的测量

另外:只有在使能了某路ADC通道,着一路enable的时候才有分压,也就是说只有在使能ADC的时候内部电阻分压才会真正的起作用。没有enable的时候如果大于3.6V的直接灌到了adc,因为内部电阻分压没有起作用,所以这里将会毁坏ADC口,当使能了adc后可以往这个ADC口接入大于3.6V的电压,但是因为ADC在默认情况下是不使能的,所以建议ADC口的电压在任何时候都不要大于3.6V!

ADC程序介绍如下:

主程序如下:int main()

{

         uint16_tx=0,adc;   

         dbg_init();

         adc_init(0);

         while(1)

         {

                   adc_open();

                   adc=get_adcval();

                   dbg_printf("adc: %04x  x:%04x \n",adc,x);

                   x++;

                   delay_ms(100);

         }

}

ADC的函数如下:

BI_CTRL_TYPE *      BI_CTRL   = ((BI_CTRL_TYPE*)        BI_CTRL_BASE);    //管脚控制寄存器

void adc_init(uint8_t cha){

         BI_CTRL->GPADC_EN=0;

         switch(cha){

                   case2:

                            PIN_CONFIG->PIN_0_SEL= PIN_SEL_ANALOG_INPUT;

                            break;

                   case3:

                            PIN_CONFIG->PIN_1_SEL= PIN_SEL_ANALOG_INPUT;

                            break;

                   default:

                            return;

         }

         BI_CTRL->GPADC_CHSEL=cha;

         BI_CTRL->GPADC_DONE=0;

}

 

uint16_t get_adcval(void){

         while(!BI_CTRL->GPADC_DONE);

         BI_CTRL->GPADC_DONE=0;

         returnBI_CTRL->GPADC_DATA;

}

 

void adc_close(void){

         BI_CTRL->GPADC_EN=0;

         BI_CTRL->GPADC_DONE=0;

}

 

void adc_open(void){

         BI_CTRL->GPADC_DONE=0;

         BI_CTRL->GPADC_EN=1;

}


校准

SYD8801通过校准芯片内部1.2V电压基准偏差来是ADC的值更叫精准

另外SYD8801的ADC模块存在着校准的问题,也就是说ADC要在经过校准之后才能够得到更加,ADC校准也是十分简单的,只要在main函数的开头调用PCSetRFVal();函数就进行了ADC的校准,该函数源代码如下:
/*
读取efuse校准如下参数:

1.    VDCDC电压校准
2.    SRAM电源校准
3.    数字LDO电源校准
4.    GPADC校准

注意:
Rom Code有一個能可以自動把 eFuse 的值填入對應的 register,但是此功能在4k_setting中    
使能,所以需要先烧录本文件目录下的4K_Setting_2000ppm.bin
*/
void PCSetRFVal(void)
{
    uint8_t val[2];
    uint8_t tmp;
    
    eFuseRead(0x00,&val[0]);
    eFuseRead(0x01,&val[1]);

    BBRFWrite(0x7F,0x00);

    BBRFRead(0x02,&tmp);
    tmp &= 0x0f;
    tmp = tmp|((val[0]&0x0F)<<4);
    BBRFWrite(0x02,tmp);

    BBRFRead(0x11,&tmp);
    tmp &= 0xF8;
    tmp = tmp|((val[0]&0x70)>>4);
    BBRFWrite(0x11,tmp);

    BBRFRead(0x3A,&tmp);
    tmp &= 0xC7;
    tmp = tmp|((val[1]&0x07)<<3);
    BBRFWrite(0x3A,tmp);

    BBRFWrite(0x7F,0x01);
    
    BBRFRead(0x70,&tmp);
    tmp &= 0x83;
    tmp = tmp|((val[1]&0xF8)>>1);
    BBRFWrite(0x70,tmp);
}

使用 参考如下:

int main()
{    
//    uint32_t SW;
    __disable_irq();
       //需要先烧录4K_Setting_2000ppm.bin文件:Rom Code自动把eFuse填入register(需要在4K_Setting中使能改功能)
    PCSetRFVal();        //读取efuse校准GPADC   //这是专门给ADC使用的语句

........................................................................................

这里上传本博客使用到的程序:http://download.csdn.net/detail/chengdong1314/9863733