This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52832 SAADC two channels at different sampling rate with burst & oversample

Hello,

I am sampling two analog signals at different sampling rate with burst and oversample enabled.

  • nRF52832 (Rigado BMD-350)
  • SDK 15.2
  • IDE - Segger Embedded Studio 4.12
  • SAADC Config
    • resolution 12bit
    • oversample 4x
    • interrupt priority = APP_IRQ_PRIORITY_LOW
    • low power mode = true
  • Channel 0 - Burst enable, sample period = 250ms
  • Channel 1 - Burst enable, sample period = 3 seconds

According to this post, https://devzone.nordicsemi.com/f/nordic-q-a/15882/sampling-two-analog-signals-using-saadc-at-two-different-rate#post-id-91845, for sampling two analog signals at different sampling rate which can be achieved by initialize and un-nitialize the channel.

Therefore I initialize and un-nitialize the channel 1 at the SAADC callback function. The first sampling result of channel 1 is OK, get the correct value. However when trigger the second sample, after initialize channel 1 and set the buffer with nrfx_saadc_buffer_convert again, the SAADC stop response, I cannot get any callback.

Below is my log and code, could anyone help me to solve this? Any idea why this is happening?

Here is the Log:

 app: ch1 uninit, ch0 cnt: 0, raw: 117
 app: ch1 uninit, ch0 cnt: 1, raw: 120
 app: ch1 uninit, ch0 cnt: 2, raw: 122
 app: ch1 uninit, ch0 cnt: 3, raw: 130
 app: ch1 uninit, ch0 cnt: 4, raw: 130
 app: ch1 uninit, ch0 cnt: 5, raw: 126
 app: ch1 uninit, ch0 cnt: 6, raw: 127
 app: ch1 uninit, ch0 cnt: 7, raw: 125
 app: ch1 uninit, ch0 cnt: 8, raw: 125
 app: ch1 uninit, ch0 cnt: 9, raw: 124
 app: ch1 uninit, ch0 cnt: 10, raw: 133
 app: ch1 init, ch0 cnt: 11, raw: 128                      <--- channel 1 init first time
 app: ch1 set uninit, ch0 cnt: 12, raw: 122                <--- channel 1 unit
 app:  ch1 result, ch1 cnt: 0, raw:3529, value: 4.1365571  <--- channel 1 get correct result
 app: ch1 uninit, ch0 cnt: 13, raw: 189
 app: ch1 uninit, ch0 cnt: 14, raw: 117
 app: ch1 uninit, ch0 cnt: 15, raw: 112
 app: ch1 uninit, ch0 cnt: 16, raw: 113
 app: ch1 uninit, ch0 cnt: 17, raw: 111
 app: ch1 uninit, ch0 cnt: 18, raw: 112
 app: ch1 uninit, ch0 cnt: 19, raw: 110
 app: ch1 uninit, ch0 cnt: 20, raw: 109
 app: ch1 uninit, ch0 cnt: 21, raw: 112
 app: ch1 uninit, ch0 cnt: 22, raw: 112
 app: ch1 init, ch0 cnt: 23, raw: 109                      <--- channel 1 init second time
<--- SAADC Stop response, no more callback

Here is my code:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "nrf.h"
//#include "nrf_drv_saadc.h"
#include "nrfx_saadc.h"
//#include "boards.h"
#include "app_timer.h"
#include "app_error.h"
#include "app_util_platform.h"
#include "nrf_pwr_mgmt.h"
#include "nrf_drv_power.h"
#include "nrf_drv_clock.h"
//#include "nrf_drv_rtc.h"
#include "nrfx_rtc.h"
#include "nrf_delay.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX