Greetings,
We are using nrf-sdk v1.3.0.
We would like to monitor an adc channel using either limit event monitoring or maybe LPCOMP.
I was able to find "low level" documentation, describing the registers and such, but no actual example code using zephyr.
https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Flpcomp.html&cp=4_0_0_5_11
https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fsaadc.html&cp=4_0_0_5_22_6&anchor=saadc_limits
What we would like to achieve is the following:
1. On device startup, sample the adc channel 1000x -> calculate average baseline value. This value would then used as the trigger threshold.
2. go to sleep
3. when the sample value on the channel is bellow 70% of threshold or above 130% of threshold, trigger an event handler in code (waking the system).
NOTE:
we know how to do #1.
The percentages in #3 are just an example, we would like to be able to change them in the code every so often.
We need to consume as little power as possible.
The comparison should be "continious", if possible. Or, if ADC must be sampled, once per second should be OK
Reading this thread:
https://devzone.nordicsemi.com/f/nordic-q-a/20895/saadc-low-power-scan-mode
I can see that this can be done, but there are not enough code samples to be able to produce something working.
Must I set the registers directly? is there no wrapper API for this?
I would be very happy to see a working code example.
Regards,
Tjaž