2022-10-07 07:22 AM
hellow.
I tried to read multiple adc using stm32h743, but I had great difficulty due to inter-channel interference.
I tried to read multiple adc using a simpler "NECTULEO-L073RZ" to find out what the problem was, but the same problem occurred.
Please help me with what the problem is.
I have already tried to read multiple adc using polling mode and interrupt mode.
The code I used below is the DMA adc read code written for "NUCLEO-L073RZ".
void MX_ADC_Init(void)
{
ADC_ChannelConfTypeDef sConfig = { 0 };
hadc.Instance = ADC1;
hadc.Init.OversamplingMode = DISABLE;
hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
hadc.Init.Resolution = ADC_RESOLUTION_12B;
hadc.Init.SamplingTime = ADC_SAMPLETIME_160CYCLES_5;
hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;
hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc.Init.ContinuousConvMode = ENABLE;
hadc.Init.DiscontinuousConvMode = DISABLE;
hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc.Init.DMAContinuousRequests = ENABLE;
hadc.Init.EOCSelection = ADC_EOC_SEQ_CONV;
hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc.Init.LowPowerAutoWait = DISABLE;
hadc.Init.LowPowerFrequencyMode = DISABLE;
hadc.Init.LowPowerAutoPowerOff = DISABLE;
if (HAL_ADC_Init(&hadc) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_0;
sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_1;
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_4;
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_8;
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_10;
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_11;
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
{
Error_Handler();
}
sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)
{
Error_Handler();
}
}
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc22)
{
HAL_ADC_Stop_DMA(&hadc);
Adceoc1 = TRUE;
}
void sensor_read(void)
{
int i = 0;
while (HAL_ADCEx_Calibration_Start(&hadc, ADC_SINGLE_ENDED) != HAL_OK);
delay_ms(500);
while (1)
{
Adceoc1 = FALSE;
HAL_ADC_Start_DMA(&hadc, buf, 7);
while (Adceoc1 != TRUE);
for (i = 0; i < MAX_ADC1_CH; i++)
Debug_Printf(" %d ", buf[i]);
Debug_Printf(" \n");
delay_ms(1000);
}
}
Each adc input pin on the "NECULEO-L073RZ" is set as follows:
3V <-> Floating repeat for a0, 0V input for a2~a6, and temperature sensor for a7.
The results are as follows.
Inter-channel interference occurs when reading multi-channel adc.
2557 2160 2 0 1 2 3763
2579 2171 2 3 0 0 3767
2586 2206 1 0 0 1 3759
358 386 1 1 1 1 0
409 483 1 0 0 1 19
2605 2281 1 1 1 0 3768
2580 2187 0 1 1 1 3764
2565 2160 0 0 0 1 3755
==============================================
additional information
===========================================
I was mistaken.
"NECTULEO-L073RZ" allows multi-adc reads to work normally when using the above code.
I will check the stm32h743 setting more and ask again if there are any difficulties.
The adc input hardware configuration of the stm32h743 board I made is shown in the picture below.
I know that there is a big input impedance problem because I omitted opamp by mistake.
In addition, due to the 16-bit adc error, a large capacitor of 220 nf was attached to the adc input terminal.
Could this hardware configuration that I configured cause interference between adc channels?