Measure voltage supplied to chip #2213
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
microprocessor.cpu.voltage
to measure the regulated voltage supplied to the chip. Monitoring of this value can detect when the regulated voltage is slumping due to a low battery.This is typically 3.3V. Note that this does not measure the actual on-chip voltage used to urn the CPU, which is often lower due to an on-chip regulator (e.g., 1.2V).
Note that we also already have brownout-detection enabled, but that simply prevents causes a reset or makes the chip refuse to start. This can catch eventual brownout in advance, before the battery gets much too low.
I use the on-chip bandgap reference and compare it with a scaled version of the supplied voltage. The SAMD51 is very touchy about how to use this reference. See https://community.atmel.com/forum/samd51-using-intref-adc-voltage-reference.
atmel-same
Processor.c
as well, to remove some confusion I introduced about ADC channels vsMUXPOS
choices.INTREF
for the temperature measurement as well, based on new info about using it for the voltage, but this still does not work.Tested using a variable bench power supply. The SAMD chips can clearly measure sag. On the nRF52840, I lost the USB connection very early when testing sag, but it still seems to work.