Skip to main content
Anassoumi
Associate III
April 17, 2024
Solved

ADC doesn't work after code gneration

  • April 17, 2024
  • 3 replies
  • 3418 views

I’ve been working on a project for a while and initially generated the code only once at the beginning to set up the hardware configuration. Recently, I updated STM32CubeIDE from version 1.14.1 to 1.15.0. After updating, I regenerated the code without making any additional configurations, yet I noticed that ADC1 and ADC2 stopped reading data. I've double-checked the configuration and the clock settings, and they appear identical to what I had previously. I also compared the HAL files, and they seem fine. All other peripherals like SPI, UART, and I2C are functioning correctly, except for the ADC. Am I missing something here?

 

 

Best answer by Anassoumi

I've identified the root cause of my ADC issue related to FreeRTOS. It turns out that the ASV bit in the PWR->SVMCR register was never enabled during the initialization phase. This bit is essential for the proper operation of analog peripherals ... I suggest that this step be included in the HAL initialization code in future updates .

Anassoumi_0-1713784437533.png

 

3 replies

raptorhal2
Lead
April 17, 2024

My first checks would be ADC registers for ADC clock and ADC Enable.

Anassoumi
AnassoumiAuthor
Associate III
April 19, 2024

I've confirmed that the clock for the ADC is enabled by checking the RCC register, but I noticed that the DRDY flag is never toggled. I compared the ADC configurations between the updated and the previous versions of the ADC drivers, and they're exactly the same. Everything worked perfectly when I started a new project with these settings. However, as soon as I introduced FreeRTOS into the mix, the ADC readings stopped functioning.

ST Employee
April 19, 2024

Hello @Anassoumi ,

As you mentioned that the problem happened once when enabling FreeRtos, so I suggest increasing the size of the heap and stack accordingly in the .ld file.

 

Kind regards,

Nissrine

ST Employee
April 18, 2024

Hello @Anassoumi ,

 

Could you please share your .ioc file to check the issue ?

 

Kind regards,

Nissrine

Anassoumi
AnassoumiAuthor
Associate III
April 18, 2024

Sure ,Project Blue.ioc is the original one i'm working with before the ADC stopped responding , Project Blue2.ioc is after the generated code , also i noticed the DRDY register of adc is never enabled for some reason , i've tried to create a new project with the updated cube ide version and worked just fine but once i enabled freertos , the adc stopped responding

Anassoumi
AnassoumiAuthor
Associate III
April 22, 2024

Can someone who has access to an stm32u5 do a simple test and confirm that adc works with freertos on the latest version of cube ide ?

Anassoumi
AnassoumiAuthorBest answer
Associate III
April 22, 2024

I've identified the root cause of my ADC issue related to FreeRTOS. It turns out that the ASV bit in the PWR->SVMCR register was never enabled during the initialization phase. This bit is essential for the proper operation of analog peripherals ... I suggest that this step be included in the HAL initialization code in future updates .

Anassoumi_0-1713784437533.png

 

ST Employee
April 22, 2024

Hello @Anassoumi 

 

I confirm the issue.
The "HAL_PWREx_EnableVddA()" must be invoked in "stm32u5xx_hal_msp.c" when activating ADCx.

This issue is internally tracked with the ID: 176661, and a fix is planned for the upcoming version.

(PS: ID: 176661 is an internal tracking number and is not accessible or usable by customers)

 

Kind regards,