研究生
最后登录1970-1-1
在线时间 小时
注册时间2015-4-30
|
求解,不知道为什么我测出来的温度这么高,配置好像也没有错啊,求大神帮忙解决,谢谢配置如下:
extern __IO uint16_t ADC_ConvertedValue;
float ADC_ConvertedValueLocal;
float temp=0;
static void adc_modeconfig(void)
{
DMA_InitTypeDef DMA_InitStructure;
ADC_InitTypeDef ADC_InitStructure;
DMA_DeInit(DMA1_Channel1);
// ///DMAéèÖÃ
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; //íaéèÎaêy¾Yà′Ô′
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; //íaéèμØÖ·1춨
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; //Äú′æμØÖ·1춨
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;//′«êäêy¾YÎa16λ
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; //′«êäêy¾YÎa16λ
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;//Ñ-»·′«êä
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //Äú′æμ½Äú′æÄ£ê½
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
DMA_Cmd (DMA1_Channel1,ENABLE);
// //ADCéèÖÃ
ADC_InitStructure.ADC_Mode=ADC_Mode_Independent;//¶àá¢Ä£ê½
ADC_InitStructure.ADC_ContinuousConvMode=ENABLE;//á¬Dø×a»»
ADC_InitStructure.ADC_ScanConvMode=DISABLE;//½ûÖ1é¨Ãèģ꽣¬é¨ÃèÄ£ê½ê1óÃóú¶àí¨μà2é¼ˉ
ADC_InitStructure.ADC_DataAlign=ADC_DataAlign_Right;//óò¶ÔÆë
ADC_InitStructure.ADC_ExternalTrigConv=ADC_ExternalTrigConv_None;//2»ê1óÃía2¿′¥·¢×a»»
ADC_InitStructure.ADC_NbrOfChannel=1;//í¨μàêy
ADC_Init(ADC1,&ADC_InitStructure);
RCC_ADCCLKConfig(RCC_PCLK2_Div6);//ÅäÖÃADCê±Öó=12MHZ
ADC_RegularChannelConfig(ADC1,ADC_Channel_16,1,ADC_SampleTime_55Cycles5);//55.5¸ö2éÑùÖüÆú
//ζè′«¸DÆ÷μÄADCí¨μàêÇADC_Channel_16
ADC_TempSensorVrefintCmd(ENABLE); //¿aÆôÄú2¿Î¶è′«¸DÆ÷
ADC_DMACmd(ADC1,ENABLE);
ADC_Cmd(ADC1,ENABLE);
ADC_ResetCalibration(ADC1);//¸′λD£×¼¼Ä′æÆ÷
while(ADC_GetResetCalibrationStatus(ADC1));//μè′yíê3é
ADC_StartCalibration(ADC1);//ADCD£×¼
while(ADC_GetCalibrationStatus(ADC1));//μè′yíê3é
ADC_SoftwareStartConvCmd(ADC1,ENABLE); //èí¼t′¥·¢ADC×a»»
}
大循环里运行:
while(1)
{
ADC_ConvertedValueLocal=(float)(ADC_ConvertedValue)*(3.3/4096);
temp=(1.43-ADC_ConvertedValueLocal)/0.0043+25;
printf("\n the current temperate value is %.3f ¶è\n",temp);
Delay(0xffffee);
}
|
|