New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use OTP Feature flag to change ADC reference source #2597
Conversation
@@ -38,6 +38,7 @@ static const nrfx_saadc_config_t saadcConfig = { | |||
|
|||
static hal_adc_reference_t adcReference = HAL_ADC_REFERENCE_EXTERNAL; | |||
static constexpr uint32_t HAL_VERSION_BRN404X_V003 = 0x03; | |||
static constexpr uint32_t HW_FEATURE_FLAG_USE_INTERNAL_ADC_REFERENCE_BIT = (1<<15); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double check endianness. Not saying this is incorrect, but a good idea to confirm it's actually bit 16 in how hal_get_device_hw_info() parses stuff and how things are provisioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hal_get_device_hw_info()
Puts the bytes in the right spots, I can examine adcReference
with debugger after HAL init and can see its detecting the cleared bit in the right spot:
(gdb) p adcReference
$1 = HAL_ADC_REFERENCE_INTERNAL
Use OTP Feature flag to change ADC reference source
Problem
There are potentially many different platforms that may end up using the richtek DCDC part with the excessive ripple voltage. For already shipped
BRN404X
platforms, theHW_VERSION
OTP field can be used to identify them. For other SKUs, we need a different method.Solution
The
HW Feature Flags
bytes of HW INFO in OTP have bits available. However, thetracker
platform uses all but one of these bits. We will use the last OTP feature flag bit to denote the presence of the RIchtek part, and thus the need to switch to the internal ADC reference voltage.Steps to Test
Example App
Burning the bit should show this
After reboot, the ADC source will be internal.
Completeness