1.设置ADC相关参数
// ADC1 configuration -----------------------------
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
2.选中ADC1的通道16作为输入
3.设置采样时间17.1 us
4.设置寄存器ADC_CR2中的TSVREFE位激活温度传感器
// ADC1 regular channel16 Temp Sensor configuration
ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 1, ADC_SampleTime_55Cycles5);
// Enable the temperature sensor and vref internal channel
ADC_TempSensorVrefintCmd(ENABLE); |