Skip to main content
Visitor II
February 18, 2025
Question

Not getting ADC ready signal (ADRDY bit) after enable STM32U5A5

  • February 18, 2025
  • 3 replies
  • 1080 views

I am working with STM32 U5A5 series of STM32 controllers and currently facing one issue with ADC1, Getting timeout when we try to enable ADC(this issue we are getting only for ADC1 and ADC4 is working as expected).

Below are the code

hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
hadc1.Init.Resolution = ADC_RESOLUTION_14B;
hadc1.Init.GainCompensation = 0;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
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.LeftBitShift = ADC_LEFTBITSHIFT_NONE;

HAL_PWREx_EnableVddA();
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
 
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADCDAC;
PeriphClkInit.AdcDacClockSelection = RCC_ADCDACCLKSOURCE_HSI;
if ( HAL_RCCEx_PeriphCLKConfig( &PeriphClkInit ) != HAL_OK )
{
printk( "ADC Peripheral clock enable failed \n" );
}
 __HAL_RCC_ADC1_CLK_ENABLE();

if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}

__HAL_RCC_GPIOC_CLK_ENABLE();

/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_4;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_5CYCLE;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}

HAL_ADCEx_Calibration_Start( &hadc1, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED );

Inside HAL_ADCEx_Calibration_Start function ADC_Enable(hadc) is called there we are getting timeout.

can anyone please help me to figure out what is missed. Same code is working fine with U575 series but getting timeout issue for U5A5 series.

    This topic has been closed for replies.

    3 replies

    Super User
    February 18, 2025

    Do you have the analog voltage domain isolation removed, i.e. PWR_SVMCR.ASV set?

    JW

    Visitor II
    February 18, 2025

    yes PWR_SVMCR.ASV set

    mohanltts_0-1739876818347.png

     

    Technical Moderator
    February 18, 2025

    Hello @mohan-ltts 

    Please refer to the example Projects/NUCLEO-U575ZI-Q/Examples/ADC/ADC_SingleConversion_TriggerSW_IT to correctly set up your configuration.

    Visitor II
    February 18, 2025

    Hello @Saket_Om ,

    In U575 board it is working as expected and with U5A5 board only we are getting timeout issue.

    Any changes we need specific to U5A5 board compare to U575?

    Thanks,

    Mohan

    Super User
    February 18, 2025

    The linked example uses the U575 and ADC1. Probably worth checking out.

    Super User
    February 18, 2025

    ADC clock enabled and running?

    Read out and check/post ADC registers content.

    JW

    Visitor II
    February 19, 2025

    ADC clock enabled.

    mohanltts_0-1739970729419.png

     

    Technical Moderator
    February 24, 2025

    Hello @mohan-ltts 

    Could you please try the following tests and check the results:

    1. Comment out the function call for the calibration step and perform HAL_ADC_Start(). Check if the function still exits in a timeout state. If yes, the issue comes from the flag ADC_FLAG_RDY and not the calibration. ADC_FLAG_RDY requires the kernel clock to be activated.
    2. In the ADC configuration, replace ADC_CLOCK_ASYNC_DIV1 with ADC_CLOCK_ASYNC_DIV4. The U5 can run at 160 MHz, and the ADC kernel clock is limited to 55 MHz. Using the prescaler ADC_CLOCK_ASYNC_DIV4 ensures that the ADC is not overclocked.