Skip to main content
RobErPOL
Associate
September 5, 2022
Solved

[Cube/HAL ADC STM32F405] One of the ADC channels seems internally pulled-up.

I am using triple simultaneuos conversion ADC (2 conversions for each) with DMA (circular):

static void MX_ADC1_Init(void)
{
 ADC_MultiModeTypeDef multimode = {0};
 ADC_ChannelConfTypeDef sConfig = {0};
 
 /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
 */
 hadc1.Instance = ADC1;
 hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
 hadc1.Init.Resolution = ADC_RESOLUTION_12B;
 hadc1.Init.ScanConvMode = ENABLE;
 hadc1.Init.ContinuousConvMode = DISABLE;
 hadc1.Init.DiscontinuousConvMode = DISABLE;
 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_RISING;
 hadc1.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T8_TRGO;
 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc1.Init.NbrOfConversion = 2;
 hadc1.Init.DMAContinuousRequests = ENABLE;
 hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
 if (HAL_ADC_Init(&hadc1) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure the ADC multi-mode
 */
 multimode.Mode = ADC_TRIPLEMODE_REGSIMULT;
 multimode.DMAAccessMode = ADC_DMAACCESSMODE_1;
 multimode.TwoSamplingDelay = ADC_TWOSAMPLINGDELAY_5CYCLES;
 if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
 */
 sConfig.Channel = ADC_CHANNEL_12;
 sConfig.Rank = 1;
 sConfig.SamplingTime = ADC_SAMPLETIME_28CYCLES;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
 */
 sConfig.Channel = ADC_CHANNEL_7;
 sConfig.Rank = 2;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
}
 
/**
 * @brief ADC2 Initialization Function
 * @param None
 * @retval None
 */
static void MX_ADC2_Init(void)
{
 ADC_ChannelConfTypeDef sConfig = {0};
 
 /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
 */
 hadc2.Instance = ADC2;
 hadc2.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
 hadc2.Init.Resolution = ADC_RESOLUTION_12B;
 hadc2.Init.ScanConvMode = ENABLE;
 hadc2.Init.ContinuousConvMode = DISABLE;
 hadc2.Init.DiscontinuousConvMode = DISABLE;
 hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc2.Init.NbrOfConversion = 2;
 hadc2.Init.DMAContinuousRequests = DISABLE;
 hadc2.Init.EOCSelection = ADC_EOC_SEQ_CONV;
 if (HAL_ADC_Init(&hadc2) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
 */
 sConfig.Channel = ADC_CHANNEL_11;
 sConfig.Rank = 1;
 sConfig.SamplingTime = ADC_SAMPLETIME_28CYCLES;
 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
 */
 sConfig.Channel = ADC_CHANNEL_14;
 sConfig.Rank = 2;
 if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
}
 
/**
 * @brief ADC3 Initialization Function
 * @param None
 * @retval None
 */
static void MX_ADC3_Init(void)
{
 ADC_ChannelConfTypeDef sConfig = {0};
 
 /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
 */
 hadc3.Instance = ADC3;
 hadc3.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
 hadc3.Init.Resolution = ADC_RESOLUTION_12B;
 hadc3.Init.ScanConvMode = ENABLE;
 hadc3.Init.ContinuousConvMode = DISABLE;
 hadc3.Init.DiscontinuousConvMode = DISABLE;
 hadc3.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc3.Init.NbrOfConversion = 2;
 hadc3.Init.DMAContinuousRequests = DISABLE;
 hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV;
 if (HAL_ADC_Init(&hadc3) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
 */
 sConfig.Channel = ADC_CHANNEL_10;
 sConfig.Rank = 1;
 sConfig.SamplingTime = ADC_SAMPLETIME_28CYCLES;
 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
 
 /** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
 */
 sConfig.Channel = ADC_CHANNEL_13;
 sConfig.Rank = 2;
 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
}

My issue is with the channel 13 of ADC3 (PC3) - it's measuring a simple voltage divider:

0693W00000SuVcKQAV.png 

Even after removing R2 and C2 the multimieter and ADC both show around 3.2V (seems internally pulled-up). When i, for example, changed pin mode to AF_OD or OUTPUT_OD the voltage was 0,6-0,8V. But if i switch back to analog the voltage goes to 3.2 no matter what. I soldered 6k8 resistor in the place of C2 to create a stronger pull-down, but that didn't change a thing...

Any ideas on what might be an issue?

This topic has been closed for replies.
AScha.3
AScha.3Best answer
Super User
September 5, 2022

maybe the chip is sick , by static discharge on this pin ... ? (shorted protection diode)

can you try another chip ?

or use other channel/pin for input , which is not already damaged , for a test ?

If you feel a post has answered your question, please click on " Best Answer ".

2 replies

AScha.3
AScha.3Best answer
Super User
September 5, 2022

maybe the chip is sick , by static discharge on this pin ... ? (shorted protection diode)

can you try another chip ?

or use other channel/pin for input , which is not already damaged , for a test ?

If you feel a post has answered your question, please click on " Best Answer ".
RobErPOL
RobErPOLAuthor
Associate
September 22, 2022

Sorry for the long time to respond, but i went with the same conclusion and switched the whole MCU with a fresh one. There was a floating ground caused by a missing 0R resistor connecting MCU ground with the one it was measuring. Thank you for the fast response and again sorry for asnwering back after so long. Have a good day!