STM32F334 HRTIM and ADC noise
- March 19, 2026
- 10 replies
- 634 views
Hello,
I am using the HRTIM on an STM32F334 to drive a buck/boost converter.
I monitor MOSFET temperature using NTCs via ADC2, and I also need to measure the internal CPU temperature and VREFINT using ADC1.
ADC configuration:
ADC1
Regular: VREFINT, TEMPSENSOR
Injected: Vin
ADC2
Regular: MosFetTemp1, MosFetTemp2, AnalogStartInfo
Injected: Vout
Issue:
As soon as the HRTIM is initialized (even without starting it), the ADC regular conversion values become unstable.
Observations:
100 samples of VREFINT only → stable when HRTIM is not initialized
100 samples of TEMPSENSOR only → stable when HRTIM is not initialized
100 samples of (VREFINT + TEMPSENSOR) → stable when HRTIM is not initialized
100 samples of (VREFINT + TEMPSENSOR + ANALOGSTARTINFO) → stable when HRTIM is not initialized
As soon as HRTIM is initialized, all these measurements become noisy/unstable.
The issue is also present:
even if HRTIM is not started
even if GPIOs are not initialized (so MOSFETs are not switching)
- even if line HAL_HRTIM_MspPostInit(&hhrtim1) is comment
Question:
Has anyone experienced a similar issue with HRTIM affecting ADC accuracy on STM32F3?
Could this be related to:
internal analog coupling between HRTIM and ADC?
ADC clocking or trigger configuration?
VDDA or internal reference disturbance caused by HRTIM initialization?
Any insights or ideas would be greatly appreciated.
Thanks in advance.
Best regards,
in main.c :
MX_GPIO_Init();
MX_ADC1_Init();
MX_ADC2_Init();
MX_HRTIM1_Init();
/* ---- Test pour debug ADC ---- */
if(HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED) != HAL_OK)
{
}
Debug_ActiveCanauxInternesAdc1();
HAL_Delay(2);
U16 volatile u16_Index = 0;
U16 volatile tu16_Data[100][2];
U16 volatile tu16_Data_2[100];
while(1)
{
U16 volatile u16_raw_vdda;
U16 volatile u16_raw_cpu;
U16 volatile u16_raw_dplus;
u16_raw_vdda = Debug_LireVddaBrut();
u16_raw_cpu = Debug_LireTempCpuBrut();
u16_raw_dplus = Debug_LireDPlus();
tu16_Data[u16_Index][0] = u16_raw_vdda;
tu16_Data[u16_Index][1] = u16_raw_cpu;
tu16_Data_2[u16_Index] = u16_raw_dplus;
//printf("TEMP raw = %u\r\n", u16_raw);
HAL_Delay(100);
u16_Index++;
if (100 <= u16_Index)
{
u16_Index = 0;
}
}
/* ------- fin test pour debug ADC ---------- */
DebugTemp.c :
void Debug_ActiveCanauxInternesAdc1(void)
{
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1),
LL_ADC_PATH_INTERNAL_VREFINT | LL_ADC_PATH_INTERNAL_TEMPSENSOR);
HAL_Delay(1);
}
U16 Debug_LireTempCpuBrut(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.SamplingTime = ADC_SAMPLETIME_601CYCLES_5;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if(HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
return 0xFFFF;
}
if(HAL_ADC_Start(&hadc1) != HAL_OK)
{
return 0xFFFE;
}
if(HAL_ADC_PollForConversion(&hadc1, 10) != HAL_OK)
{
return 0xFFFD;
}
return (U16)HAL_ADC_GetValue(&hadc1);
}
U16 Debug_LireVddaBrut(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
sConfig.Channel = ADC_CHANNEL_VREFINT;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.SamplingTime = ADC_SAMPLETIME_181CYCLES_5;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if(HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
return 0xFFFF;
}
if(HAL_ADC_Start(&hadc1) != HAL_OK)
{
return 0xFFFE;
}
if(HAL_ADC_PollForConversion(&hadc1, 10) != HAL_OK)
{
return 0xFFFD;
}
return (U16)HAL_ADC_GetValue(&hadc1);
}
U16 Debug_LireDPlus(void)
{
ADC_ChannelConfTypeDef sConfig = {0};
sConfig.Channel = ADC_CHANNEL_4;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.SamplingTime = ADC_SAMPLETIME_19CYCLES_5;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if(HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)
{
return 0xFFFF;
}
if(HAL_ADC_Start(&hadc2) != HAL_OK)
{
return 0xFFFE;
}
if(HAL_ADC_PollForConversion(&hadc2, 10) != HAL_OK)
{
return 0xFFFD;
}
return (U16)HAL_ADC_GetValue(&hadc2);
}
