ADC采集比较简单,内部的10位的ADC,AIN0-AIN3的输入,主要是用的CSL的库函数#include <csl_adc.h>
Uint32 adc_sample_value = 0;
Uint16 samplestoraage[2]={0,0};
unsigned char adc_value_baiwei = 0;
unsigned char adc_value_shiwei = 0;
unsigned char adc_value_gewei = 0;
int sysclkdiv=2,convratediv=0,sampletimediv=79;
int counter=0,index=0;
int channel=1,samplenumber=2;
/* Initialize CSL library - This is REQUIRED !!! */
/*初始化CSL库*/
CSL_init();
/*设置系统的运行速度为140MHz*/
PLL_config(&myConfig);
ADC_setFreq(sysclkdiv,convratediv,sampletimediv);
ADC_read(channel,samplestoraage,samplenumber);
adc_sample_value = (samplestoraage[0] + samplestoraage[1])/2;
adc_sample_value = (adc_sample_value * 330)/1024;
adc_value_baiwei = adc_sample_value/100; //ADC电压值个位
adc_value_shiwei = adc_sample_value%100/10; //ADC电压值小数点后一位
adc_value_gewei = adc_sample_value%10;//ADC电压值小数点后两位