cancel
Showing results for 
Search instead for 
Did you mean: 

ADC doesn't work after code gneration

Anassoumi
Associate III

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?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

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

 

View solution in original post

9 REPLIES 9
raptorhal2
Lead

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

NEL M.1
ST Employee

Hello @Anassoumi ,

 

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

 

Kind regards,

Nissrine

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

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.

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

Hello, increasing the heap and stack sizes hasn't resolved the issue. I've tried starting a new project with just the ADC enabled, and it works perfectly until I activate FreeRTOS; then the ADC stops working. I've ensured that both the stack and heap are sufficiently increased in the .ld file and in the FreeRTOSConfig file. What could be causing this issue?

Anassoumi
Associate III

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 ?

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

 

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,