Page 2 of 2

Re: overdischarge protection

Posted: Mon Mar 19, 2018 3:02 pm
by gpson

Re: overdischarge protection

Posted: Mon Mar 19, 2018 3:46 pm
by dhylands
The stm constants are automatically generated from the CMSIS headers, and I'm going to guess that the CMSIS headers changed along the way.

I'm pretty sure that the new name for 'ADC' is now 'ADC123_COMMON'

Re: overdischarge protection

Posted: Mon Mar 19, 2018 6:06 pm
by chuckbook
Assuming you are using a pyboard I would suggest the following as a first trial.

Code: Select all

import pyb
adc = pyb.ADCAll(12, 0x70000)
print('%.2f' % adc.read_vref())
This will give you the actual Vref which is the operation voltage of the MCU.

Re: overdischarge protection

Posted: Tue Mar 20, 2018 5:59 am
by pythoncoder
dhylands wrote:
Mon Mar 19, 2018 3:46 pm
...
I'm pretty sure that the new name for 'ADC' is now 'ADC123_COMMON'
I have a PR awaiting attention which extends the ADC functionality and replaces this outdated example code. At some point the firmware has improved so you can read individual channels without using ADCAll. And, as @chuckbook has pointed out, a mask parameter for the ADCAll object can also be used to modify its default of turning on all the ADC's.

So we now have two ways of reading voltage without needing the stm library. As so often happens the docs lag the code.