I use nRF52832 SAADC to measure battery voltage. But I encounter <err> adc_nrfx_saadc: Channel 0 not configured, adc_read() failed, ret=-22. Do you have suggestion to configure channel 0? What is meaning of error code -22?
00> *** Booting Zephyr OS build v3.3.99-ncs1 *** 00> btInit() e 00> _btReady(0) e 00> Bluetooth initialized 00> _btReady(0) x 00> btInit() x 00> [00:00:00.006,011] <dbg> fs_nvs: nvs_recover_last_ate: Recovering last ate from sector 0 00> [00:00:00.012,542] <inf> fs_nvs: 3 Sectors of 4096 bytes 00> [00:00:00.012,573] <inf> fs_nvs: alloc wra: 0, fe8 00> [00:00:00.012,573] <inf> fs_nvs: data wra: 0, 0 00> [00:00:00.012,603] <err> adc_nrfx_saadc: Selected ADC gain is not valid 00> [00:00:00.012,603] <err> battery: adc_channel_setup() failed, errCode=-22 00> configure POWER_UP pin as output 00> configure LED_G pin as output 00> set POWER_UP pin 00> device_is_ready() ok 00> nrfx_gpiote_input_configure() okay for button 00> val=0 00> button pressed 00> start a timer 00> 12 00> lis2dh12 device is ready! 00> LIS2DH12 ID check ok, id=0x33 00> lis2dh12 ID check pass! 00> _buttonTimerHandler: 3012 00> button released 00> Button pressed at 132376 00> start a timer 00> 4039 00> _buttonTimerHandler: 7039 00> button pressed 00> power up 00> connected() e 00> Connected F0:92:AF:29:DA:F8 (random) 00> btInfo.le.interval=6 00> btInfo.le.latency=0 00> btInfo.le.timeout=400 00> _gCurrentConn=0x200021f8 00> state = connect 00> btNusThreadCreate() e 00> connected() x 00> _basTimerHandler: 30692 00> batteryVoltageEnable(1) e 00> Enabling battery measurement ok 00> [00:00:30.692,657] <err> adc_nrfx_saadc: Channel 0 not configured 00> adc_read() failed, ret=-22
Procedures to reproduce this issue are as follows.
1. Unzipping custom_nrf52832.zip to C:\ncs\v2.4.0\nrf\boards\arm folder.
2. Unzipping minimal_log_battery.zip to C:\ncs\v2.4.0\nrf\samples folder.
3. cd C:\ncs\v2.4.0\nrf\samples\minimal_log_battery
4. west build -b custom_nrf52832
5. west flash
6. Rebooting nRF52832 device and connecting to nRF Connect Windows APP.