CH579? ADC采集電壓時(shí),接0V測(cè)量數(shù)值有1120左右,接1.5V測(cè)量數(shù)值有3100左右,接3.0V測(cè)量數(shù)值只有3900左右?用示波器測(cè)量管腳電壓都是正常,但讀出來(lái)的數(shù)據(jù)為何如此?
#include?"CH57x_common.h" UINT16?abcBuff[40]; volatile?UINT8??adclen; void?DebugInit(void) { ????GPIOA_SetBits(GPIO_Pin_9); ????GPIOA_ModeCfg(GPIO_Pin_8,?GPIO_ModeIN_PU); ????GPIOA_ModeCfg(GPIO_Pin_9,?GPIO_ModeOut_PP_5mA); ????UART1_DefInit(); } int?main() { ????UINT8?i; ????signed?short??RoughCalib_Value=0; //?ADC粗調(diào)偏差值 ???? /*?配置串口調(diào)試?*/??? ????DebugInit(); ????PRINT(?"Start?@ChipID=%02X\n",?R8_CHIP_ID?); /*?單通道采樣:選擇adc通道9做采樣,對(duì)應(yīng)?PA0引腳,?帶數(shù)據(jù)校準(zhǔn)功能?*/??? ????PRINT(?"\n2.Single?channel?sampling...\n"); ????GPIOA_ModeCfg(GPIO_Pin_0,?GPIO_ModeIN_Floating); ????ADC_ExtSingleChSampInit(?SampleFreq_3_2,?ADC_PGA_1_2?); ???? /*? ????注意:數(shù)據(jù)校準(zhǔn)包括?粗調(diào)和細(xì)調(diào): ????ADC_DataCalib_Rough()?是粗調(diào)函數(shù),調(diào)用前需保證PA5引腳配置浮空輸入模式,外部沒(méi)有電壓信號(hào),在ADC初始化之后調(diào)用,一般調(diào)用一次,除非更改了ADC模式(增益改變) ????ADC_DataCalib_Fine()?是細(xì)調(diào)函數(shù),對(duì)于粗調(diào)過(guò)的數(shù)據(jù)進(jìn)行擬合算法運(yùn)算,得到更精確數(shù)據(jù) */???? ????GPIOA_ModeCfg(GPIO_Pin_5,?GPIO_ModeIN_Floating); ????RoughCalib_Value?=?ADC_DataCalib_Rough();??//?用于計(jì)算ADC內(nèi)部偏差,記錄到全局變量?RoughCalib_Value中?? ????PRINT("=%d?\n",?RoughCalib_Value);? ????while(1) {???? ????int?sum=0; ADC_ChannelCfg(?9?);???????? for(i=0;?i<21;?i++) { abcBuff[i]?=?ADC_ExcutSingleConver()?+?RoughCalib_Value;??????//?連續(xù)采樣20次 ADC_DataCalib_Fine(?&abcBuff[i],?ADC_PGA_1_2?); if(i>=1) {sum?+=?abcBuff[i];} } printf("ADC值:%d\r\n",sum/20); } }