Fix the XIAO battery reading: busy-wait for the divider to settle
At CONFIG_FREERTOS_HZ=100 pdMS_TO_TICKS(5) is zero ticks, so the switched divider had not settled when the ADC was read and battery_mv came out as 0. Wait 5 ms with esp_rom_delay_us and configure GPIO26 with gpio_config. The XIAO on COM10 now reads 4153-4156 mV on a charging cell.
This commit is contained in:
@@ -52,6 +52,11 @@ custom PCB; pick it in `menuconfig -> micrOBU firmware -> Board`.
|
||||
protection board, so `battery_policy.hpp` (smoothing, warning hysteresis, shutdown) deep-sleeps the
|
||||
board below 3.30 V for 30 s when no phone is on USB, re-checks every 5 min, and runs again from
|
||||
3.60 V. Thresholds: `menuconfig -> micrOBU firmware`.
|
||||
- **Battery reading fix** (`battery_monitor.cpp`, found on the XIAO 2026-11-11: `battery_mv` was 0). At
|
||||
`CONFIG_FREERTOS_HZ=100` `vTaskDelay(pdMS_TO_TICKS(5))` is zero ticks, so the switched divider never
|
||||
settled before the ADC read it and every sample fell below the 2.5 V validity floor. It is now a 5 ms
|
||||
busy wait, and GPIO26 is set up with `gpio_config`. Worth telling Niklas Dathe: his mainboard-v5 has no
|
||||
switched divider and is not affected. With the fix the XIAO reads 4153-4156 mV on a charging cell.
|
||||
- **Serial link**: no write attempt while no USB host is connected; `last_frame_ms()` tells the battery
|
||||
guard whether a phone is powering the board.
|
||||
- **Partition table**: 80 KB NVS (Niklas Dathe's 24 KB filled up and BLE bonds stopped persisting),
|
||||
|
||||
Reference in New Issue
Block a user