You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This applies at least on the NucleoL476 sample code, probably worth looking at the other STM32 sample code as well.
This line sets the ADC sampling time to 92 cycles for every ADC read. The problem is that when it's this low, it makes BoardBatteryMeasureVoltage return incorrect values when the input voltage is under 2.6 volts. We were able to solve this by changing the ADC sampling time to 640 cycles (ADC_SAMPLETIME_640CYCLES_5). This does slightly increase the amount of time the ADC takes to read, but given that AdcMcuReadChannel recalibrates the ADC every time it does a read, I'm assuming ADC read performance isn't a priority anyway.
The text was updated successfully, but these errors were encountered:
Some objective numbers rather than doing things empirically:
The STM32L476 datasheet (rev 11) says on page 117 that the minimum ADC sampling time when reading the internal voltage reference is 4us. When running the processor at 80MHz and not dividing the AHB clock or the ADC clock, 92 cycles corresponds to around 1.15us (not enough time) while 640 cycles corresponds to around 8us (enough time).
This applies at least on the NucleoL476 sample code, probably worth looking at the other STM32 sample code as well.
This line sets the ADC sampling time to 92 cycles for every ADC read. The problem is that when it's this low, it makes BoardBatteryMeasureVoltage return incorrect values when the input voltage is under 2.6 volts. We were able to solve this by changing the ADC sampling time to 640 cycles (
ADC_SAMPLETIME_640CYCLES_5
). This does slightly increase the amount of time the ADC takes to read, but given that AdcMcuReadChannel recalibrates the ADC every time it does a read, I'm assuming ADC read performance isn't a priority anyway.The text was updated successfully, but these errors were encountered: