I manage to make this work with nrf52832dk.
https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src/nrfx_saadc/advanced_non_blocking_internal_timer
But what I want to achieve is to capture 1 sample evey 1ms and writing the the 20 samples to notify central.
Currently I have set the ADC to oversampling with NRF_SAADC_ACQTIME_20US.
1. How do I make sure that the buffer array contains 20 of my samples , sampled at 1ms per sample where per sample is average of the samples taken in 1ms?
In other words if I understand it right 1sample with oversampling at 1ms is the average of the samples taken during that 1ms? How can I achieve that?
2. I am currently using k_msleep(20) before writing the ble characteristic in a while loop with fix ble write values as testing. The problem is sometimes the nrf sniffer shows empty buff from slave from time to time. And I can't use workqueue or zephyr timer afaik since it may cause deadlock with ble notify.
devzone.nordicsemi.com/.../bt_gatt_notify-can-block-when-running-on-zephyr-workqueue