2025-10-23 6:19 AM
Hi,
I have a custom board with STM575VGT6 then we decided to make it smaller and move to STM32U585OI MCU.
On the second board with new MCU, almost all peripherals works fine (DAC, UART, I2C) with almost no code changes, except new MCU defines, drivers etc.
But we have troubles with ADC, it acts very strange. So I decided to write a simple code to test ADC.
void MX_ADC1_Init(void) {
/* USER CODE BEGIN ADC1_Init 0 */
/* USER CODE END ADC1_Init 0 */
ADC_ChannelConfTypeDef sConfig = {0};
HAL_PWREx_EnableVddA();
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableVddA();
HAL_PWREx_EnableVddIO2();
/* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV256;
hadc1.Init.Resolution = ADC_RESOLUTION_14B;
hadc1.Init.GainCompensation = 0;
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = DISABLE;
hadc1.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH;
hadc1.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;
hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
hadc1.Init.OversamplingMode = DISABLE;
if(HAL_ADC_Init(&hadc1) != HAL_OK) {
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_7;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_36CYCLES;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if(HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) {
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
if(HAL_ADCEx_Calibration_Start(&hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED) != HAL_OK) {
Error_Handler();
}
if(HAL_ADC_Start(&hadc1) != HAL_OK) {
Error_Handler();
}
/* USER CODE END ADC1_Init 2 */
}
void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle) {
GPIO_InitTypeDef GPIO_InitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
if(adcHandle->Instance == ADC1) {
/* USER CODE BEGIN ADC1_MspInit 0 */
/* USER CODE END ADC1_MspInit 0 */
/** Initializes the peripherals clock
*/
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADCDAC;
PeriphClkInit.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_SYSCLK;
if(HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
Error_Handler();
}
/* ADC1 clock enable */
__HAL_RCC_ADC12_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**ADC1 GPIO Configuration
PA0 ------> ADC1_IN5
PA2 ------> ADC1_IN7
PA3 ------> ADC1_IN8
PA6 ------> ADC1_IN11
*/
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_6 | GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
/*
//main loop code
adc_st = HAL_ADC_PollForConversion(&hadc1, 1000);
if(adc_st != HAL_OK) {
//Error_Handler();
SEGGER_RTT_printf(0, "adc err %u\r\n", adc_st);
}
uhADCxConvertedData = HAL_ADC_GetValue(&hadc1);
vTaskDelay(500);
*/1. When nothing is connected, it shows 3.3V
2. When I conned it to some signal source, It shows 0 up to 2.5 V, then start to show some strange values from 0 to 3.3V
3. When signal is 3V and more, it shows 3.3V
About the schematic, VREF+ and VDDA is connected to 3.3V.
__HAL_RCC_VREF_CLK_ENABLE();
HAL_SYSCFG_DisableVREFBUF();
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE);
Whats is also strange,
Solved! Go to Solution.
2025-10-23 11:51 PM
Sorry to bother you, the problem is in the soldering.
After some tries to resolder the chip, I get correct ADC and VBAT is 0.8V.
So, I guess we need to rework PCB around the MCU, or check the footprint, if all 7 boards have adc solder problems.
Thank you for the answers!
2025-10-23 6:54 AM - edited 2025-10-23 6:54 AM
> STM575VGT6
No such chip. STM32U575VGT6 maybe?
Most likely a hardware problem. Sounds like current is leaking somewhere. Perhaps VREF+ is not stable, being pulled down, or not connected well. If you have the ability to x-ray the board to verify solder connections, I'd do that, especially around VREF/VDDA/VSSA.
Do you have just one of these boards or multiple? Do they all behave the same?
Also wouldn't hurt to show the schematic, if you can.
2025-10-23 9:41 PM
Thank you for the answer,
1. Yes, mistype, the MCU is STM32U575VGT6
2. I have few boards and all of them are strange
3. I include schematic of MCU Power, R36 is soldered and it's 0 Ohm
4. I am curious about ADC_CHANNEL_VBAT, in what cases it could show 3.3V instead of 0.8
5. What is also strange, DAC is working well, thats why I think that VREF/VDDA/VSSA are OK
2025-10-23 11:51 PM
Sorry to bother you, the problem is in the soldering.
After some tries to resolder the chip, I get correct ADC and VBAT is 0.8V.
So, I guess we need to rework PCB around the MCU, or check the footprint, if all 7 boards have adc solder problems.
Thank you for the answers!