以下代码是我从STM32H533的例程Examples/ADC/ADC_MultiChannelSingleConversion/Src/main.c中摘录的代码
/* If ADC conversions and DMA transfer are completed, then process data */
if(ubDmaTransferStatus == 1)
{
/* For this example purpose, calculate analog reference voltage (Vref+) */
/* from ADC conversion of internal voltage reference VrefInt. */
/* This voltage should correspond to value of literal "VDDA_APPLI". */
/* Note: This calculation can be performed when value of voltage Vref+ */
/* is unknown in the application */
/* (This is not the case in this example due to target board */
/* supplied by a LDO regulator providing a known constant voltage */
/* of value "VDDA_APPLI"). */
/* In typical case of Vref+ connected to Vdd, it allows to */
/* deduce Vdd value. */
uhADCxConvertedData_VrefAnalog_mVolt = __LL_ADC_CALC_VREFANALOG_VOLTAGE(uhADCxConvertedData[1], LL_ADC_RESOLUTION_12B);
/* Computation of ADC conversions raw data to physical values */
/* using LL ADC driver helper macro. */
uhADCxConvertedData_VoltageGPIO_mVolt = __LL_ADC_CALC_DATA_TO_VOLTAGE(uhADCxConvertedData_VrefAnalog_mVolt, uhADCxConvertedData[0], LL_ADC_RESOLUTION_12B);
uhADCxConvertedData_VrefInt_mVolt = __LL_ADC_CALC_DATA_TO_VOLTAGE(uhADCxConvertedData_VrefAnalog_mVolt, uhADCxConvertedData[1], LL_ADC_RESOLUTION_12B);
hADCxConvertedData_Temperature_DegreeCelsius = __LL_ADC_CALC_TEMPERATURE(uhADCxConvertedData_VrefAnalog_mVolt, uhADCxConvertedData[2], LL_ADC_RESOLUTION_12B);
/* Update status variable of DMA transfer */
ubDmaTransferStatus = 0;
/* Toggle LED 4 times */
tmp_index = 4*2;
while(tmp_index != 0)
{
BSP_LED_Toggle(LED2);
HAL_Delay(LED_BLINK_FAST);
tmp_index--;
}
HAL_Delay(500); /* Delay to highlight toggle sequence */
}
我没有修改过任何例程或配置,但是程序执行到214行的uhADCxConvertedData_VrefAnalog_mVolt = __LL_ADC_CALC_VREFANALOG_VOLTAGE(uhADCxConvertedData[1], LL_ADC_RESOLUTION_12B);
该程序出现了硬件错误。
该段程序是我在测试DMA采集ADC时发现的。后我使用ADC_MultiChannelSingleConversion也出现了同样的错误。
|