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;
}
自帶的函數(shù) 也沒有對?ADC_OutputBuffer,ADC_Pga沒有初始化
例子也沒有初始化 這兩個參數(shù)?ADC_OutputBuffer,ADC_Pga
*** 嚴重表示不滿 折騰了一天才找出來 ***