2023-05-29 03:29 AM
We are using the STM32WLE5JCI6 chip and we are mostly done with hardware and software development but got stuck with the below issues.
We are trying to read two analog inputs from PB4 (ADC1_IN3) and ADC_CHANNEL_VREFINT. (We are using a Lithium thionyl battery so we do not have a fixed voltage)
1. ADC_ReadChannels(ADC_CHANNEL_3) ---> from pin PB4 (ADC1_IN3)
2. ADC_ReadChannels(ADC_CHANNEL_VREFINT) ---> from Internal voltage reference
(1) From pin PB4:
We expected ADC_CHANNEL_3 to have the input data of PB4.
We expect half of the input voltage at the ADC pin as we have added a voltage divider network. However, ADC_CHANNEL_3 always gives data of around 2050 mV.
So, please let us know what is the problem here?
Where we are measuring the same on DMM and it shows the expected value.
For example:
By giving input as 3600 mV,
- While measuring using DMM on pin PB4, it shows the expected value as around 1800 mV.
- But, by reading in code using ADC_ReadChannels(ADC_CHANNEL_3), it shows a value around 2050 mV (Raw_Vsens_mV: 2050 mV) which is not expected. Also, this Raw_Vsens_mV value is fixed for the voltage input range from 2000 mV to 3700 mV.
(2) From ADC_CHANNEL_VREFINT:
We expected ADC_CHANNEL_VREFINT to have the input data of Internal voltage reference.
We expect a fixed voltage at the ADC pin. But we are getting variable data with respect to the input voltage.
So, please let us know what is the issue between the raw value and reference pin?
We assume that reference voltage is fixed and ADC is variable but in our case, it gives opposite values. (i.e. PB4 ADC as a fixed value and Vref as a variable value)
For example:
By giving input as 3600 mV,
- By reading raw value using ADC_ReadChannels(ADC_CHANNEL_VREFINT), it shows a value around 1382 mV. So this value is expected or not?
- And by converting this value (1382 mV) using equation _LL_ADC_CALC_VREFANALOG_VOLTAGE(measuredLevel, ADC_RESOLUTION_12B), it gives a value as 3593 mV.
Note:
- We are planning to make around 20k boards in the next three months.
We anticipate your swift response to ensure that this issue can be resolved in a timely manner, and to maintain the mutually beneficial business relationship we have established.
Your prompt response would be appreciated.
2023-05-29 04:35 AM
Both signal sources are high impedance. Low sampling cycles can give erroneous results.
If ADC calibration is available for this device, not calibrating can also produce erroneous results.
2023-05-29 04:45 AM
Do you have any stabilizer between the battery and the MCU?
If not, the measured voltage (derived from the resistive divider) will be in constant ratio to the ADC reference voltage (which is the supply voltage). The voltage measured on the internal reference will then depend on the supply voltage (which is also the reference for the AD converter).