void ADC_Init(ADC_TypeDef *ADCx, ADC_InitTypeDef *ADC_InitStruct)
{
uint32_t tmpreg1 = 0;
uint8_t tmpreg2 = 0;
tmpreg1 = ADCx->CTLR1;
tmpreg1 &= CTLR1_CLEAR_Mask;
tmpreg1 |= (uint32_t)(ADC_InitStruct->ADC_Mode | (uint32_t)ADC_InitStruct->ADC_OutputBuffer |
(uint32_t)ADC_InitStruct->ADC_Pga | ((uint32_t)ADC_InitStruct->ADC_ScanConvMode << 8));
ADCx->CTLR1 = tmpreg1;
...
}
ADC_OutputBuffer,ADC_Pga没有初始化 也没有 and 位 直接 or
可能想象不到的错误
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
{
ADC_InitStruct->ADC_Mode = ADC_Mode_Independent;
ADC_InitStruct->ADC_ScanConvMode = DISABLE;
ADC_InitStruct->ADC_ContinuousConvMode = DISABLE;
ADC_InitStruct->ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;
ADC_InitStruct->ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStruct->ADC_NbrOfChannel = 1;
}
自带的函数 也没有对 ADC_OutputBuffer,ADC_Pga没有初始化
例子也没有初始化 这两个参数 ADC_OutputBuffer,ADC_Pga
*** 严重表示不满 折腾了一天才找出来 ***