//回调函数,定时器中断服务函数调用
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim==(&TIM3_Handler))
{
adc_t++;
if(adc_t==100)//ADC 200ms采样
{
adc_t=0;
adcx=Get_Adc_Average(ADC_CHANNEL_9,20);//ADC原始值
temp=(float)adcx*(3.3/4096);//ADC电压值
adcx1=temp;
temp-=adcx1;
temp*=1000;
}
switch(smg_wei)
{
//ADC采样值
case 0:
if(adcx>1000)num = smg_num[adcx/1000];
else num = 0x00;
break;
case 1:
if(adcx>100) num = smg_num[adcx%1000/100];
else num = 0x00;
break;
case 2:
if(adcx>10) num = smg_num[adcx%100/10];
else num = 0x00;
break;
case 3:
num = smg_num[adcx%10];
break;
case 4: num = 0x00; break;
//ADC换算后的电压值
case 5: num = smg_num[adcx1]|0x01;break;
case 6: num = smg_num[(u16)temp/100]; break;
case 7: num = smg_num[(u16)temp%100/10];break;