提問
void MX_ADC3_Init(void)
{
ADC_MultiModeTypeDef multimode = {0};
ADC_ChannelConfTypeDef sConfig = {0};
hadc3.Instance = ADC3;
hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc3.Init.Resolution = ADC_RESOLUTION_12B;
hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc3.Init.GainCompensation = 0;
hadc3.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc3.Init.LowPowerAutoWait = DISABLE;
hadc3.Init.ContinuousConvMode = ENABLE;
hadc3.Init.NbrOfConversion = 1;
hadc3.Init.DiscontinuousConvMode = DISABLE;
hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc3.Init.DMAContinuousRequests = DISABLE;
hadc3.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc3.Init.OversamplingMode = DISABLE;
if (HAL_ADC_Init(&hadc3) != HAL_OK)
{
Error_Handler();
}
/** Configure the ADC multi-mode
*/
multimode.Mode = ADC_MODE_INDEPENDENT;
if (HAL_ADCEx_MultiModeConfigChannel(&hadc3, &multimode) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_1;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_92CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC3_Init 2 */
/* USER CODE END ADC3_Init 2 */
}
HAL_ADCEx_Calibration_Start(&hadc3, ADC_SINGLE_ENDED);
HAL_ADC_Start(&hadc3);
仿真時,查看DR寄存器,只有在開始運(yùn)行仿真時轉(zhuǎn)換一次就不再轉(zhuǎn)換,改成外部TIM觸發(fā)也只是能轉(zhuǎn)換一次,是哪里配置錯誤嗎?
最新回答
我看你的配置,單個通道,連續(xù)轉(zhuǎn)換。估計是誤會了,肯定是啟動了,不然一個結(jié)果也沒有。
可能調(diào)試模塊沒有做更新,你也沒有啥操作。
保持現(xiàn)有 配置的前提下,你這樣試試,先軟件啟動ADC,然后查詢接收,再看看結(jié)果。
int main(void)
{。。。。。。
。。。。。。uint8_t i=0;
HAL_ADC_Start(&hadc1);
while (1)
{if (HAL_ADC_PollForConversion(&hadc1, 888) != HAL_OK)
{Error_Handler();
}AdcResulti++] = HAL_ADC_GetValue(&hadc1);
if(i==9) i=0;
} //while(1)
} //main