My_GetAdc.c 1.65 KB
#include "hardware.h"
#include "math.h"
#include "sys.h"
#include "all_value.h"
#include "My_GetAdc.h"
//float Vol[2]={0,0};//采集的电压

//u16  VolAll[2]={0,0};//采集的电压

//u8 VolGetNums[2]={0,0};//采集的电压
//u8 VolWorking[2]={0,0};//采集的电压
//u8 VoChanel;	
//void Get_Adca(u8 ch,u8 times)  //此输出是对应口的当前时刻的真实采集信息,数字信号值,可能会有干扰
//{

//	if (ch==ADC_Channel_4)VoChanel=0;
//	else if (ch==ADC_Channel_5)VoChanel=1;	
//	
////		if ((VoChanel==0) &&(TIM3_AdcNums[0]>=10)&&(VolWorking[0]==0)&&(VolWorking[1]==0))
////{VolWorking[0]=1;
////VolWorking[1]=0;}
////		if ((VoChanel==1) &&(TIM3_AdcNums[1]>=10)&&(VolWorking[1]==0)&&(VolWorking[0]==0))
////{VolWorking[1]=1;
////VolWorking[0]=0;}	
//		
//	if ((TIM3_AdcNums[VoChanel]>=10)&&(VolWorking[VoChanel]==1))
//	{		

//		
//		ADC_RegularChannelConfig(ADC1,ch,1, ADC_SampleTime_480Cycles );			     
//		ADC_SoftwareStartConv(ADC1);	
////		ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC );
////		if (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC ))
////		{		

//////				VolAll[VoChanel]+=ADC_GetConversionValue(ADC1);
////				TIM3_AdcNums[VoChanel]=0;
//////				VolGetNums[VoChanel]++;
////						VolWorking[VoChanel]=0;
////			
//////				if (VolGetNums[VoChanel]>=times)
//////				{
//////					Vol[VoChanel]=(float)VolAll[VoChanel]/times/4096*3.3*3.2;
//////					VolGetNums[VoChanel]=0;VolAll[VoChanel]=0;}
////					Vol[VoChanel]=(float)ADC_GetConversionValue(ADC1)/4096*3.3*3.2;
////				TIM3_AdcWaitNums[VoChanel]=0;
////		}	
////		else
////		{ 
////			if(TIM3_AdcWaitNums[VoChanel]>=100)
////			{
////				if (Ceshi[9]){
////			Vol[VoChanel]=0;
////			VolGetNums[VoChanel]=0;
////			VolAll[VoChanel]=0;}
////				}
////		}
//	}
//}