-
Could do with some assistance to resolve battery voltage monitoring ADC code that works with Zephyr 3.4 but no longer works with 3.5. The code,shown below, which is the first part of a battery monitoring function, initially attempts to read the reference voltage from the internal reference channel 17 for calibration purposes.
dts for the board is:
Which in Zephyr 3.4 referenced stm32l0.dtsi with ADC as follows:
In 3.5 this has become:
Would appreciate a steer on how to fix the indicated problem. PS - Comparing STM32 adc driver code between v3.4.0 and v3.5.99 it appears that for some unknown reason STM has dropped code that configures adc to read internal channels vbat, vtemp and vref (e.g. for vref setting VREFEN bit in the ADC_CCR register). No wonder there is no sensible output. So right now it appears that a supplementary driver will need to be written. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Ok, so responding to my own question now it seems, which hopefully will be helpful to others.
Have no idea why STM removed the code that takes care of enabling internal ADC channels from this latest version of zephyr 3.5.99, with the above being unnecessary in zephyr 3.4.0. Be very interested if somebody could say why this was done. |
Beta Was this translation helpful? Give feedback.
-
Did you run the
The value should come on the console, reading channel 17:
|
Beta Was this translation helpful? Give feedback.
Ok, so responding to my own question now it seems, which hopefully will be helpful to others.
To enable Vref output for its internal adc channel (would be the same for temp and vbat internal), there may be a better approach but in any case I did the following:
#include <soc.h>
to the application main.cHAL_ADCEx_EnableVREFINT( );
then after adc_read addHAL_ADCEx_DisableVRE…