52832 ADC just do samle one time

Alice gravatar image

asked 2017-07-14 09:17:24 +0200

updated 2017-07-17 14:04:41 +0200


I'm using the ADC of nRF52832 on nRF5 SDK V12.2. The setting as attachment. I found that it just do sample one time. But I have use timer to call nrf_drv_saadc_sample() to the SAADC sample task every second. However, I just can see one adc result and the result is correct. Could you help me have a look? Thanks.



edit retag flag offensive close delete report spam


Your code does not show how you trigger sampling. It is very hard to say why it only trigger one sample without seeing the rest of your code. Do you know if your code continues to run or if it halts at an error? What is the size of SAADC_SAMPLES_IN_BUFFER?

Jørgen Holmefjord ( 2017-07-14 11:35:26 +0200 )editconvert to answer

I use APP_TIMER_DEF(m_battery_voltage_id);to creat a timer and then I use nrf_drv_saadc_sample() to trigger the ADC to sample when the timer timeout. The SAADC_SAMPLES_IN_BUFFER is 1, I also try other number such as 5, but the result is the same. I know the code is runing well ,because the timer is running all the time and I will prinf a debug information when timer timeout.

Alice ( 2017-07-17 04:25:41 +0200 )editconvert to answer

Could you upload the code for review/debugging?

Jørgen Holmefjord ( 2017-07-17 13:05:42 +0200 )editconvert to answer

The whole project is too large, so I upload the main.c document, pls see the attachment. Thanks.

Alice ( 2017-07-17 14:06:02 +0200 )editconvert to answer

I can't see anything in particular that should stop the sampling after one sample, but you should try checking all error codes, to make sure no functions return errors:

In battery_voltage_timeout_handler(), check the error code from nrf_drv_saadc_sample():

uint32_t err_code = nrf_drv_saadc_sample(); //Trigger the SAADC SAMPLE task

You should also check error codes on calls to app_timer_create and app_timer_start.

Jørgen Holmefjord ( 2017-07-17 16:57:01 +0200 )editconvert to answer

Just a blind shot, because I cannot check your code right now. Do you start SAADC after each sampling? You have to.

Wojtek ( 2017-07-17 17:11:21 +0200 )editconvert to answer

Hi Jørgen , I check the err_code for the nrf_drv_saadc_sample as you said, no error. Do you have a similar example that adc works at low power mode? I have no idear to solve the problem. It's too stranged.

Alice ( 2017-07-18 11:12:16 +0200 )editconvert to answer

Hi Wojtek, yes, I have started SAADC after each sampling.

Alice ( 2017-07-18 11:13:51 +0200 )editconvert to answer

1 answer

Sort by » oldest newest most voted
joh2 gravatar image

answered 2017-07-18 13:57:22 +0200

Hi Alice,

I see you use low power mode in the SAADC driver. There is some issues with this mode in SDK 12.x.0 driver. You should use the driver (nrf_drv_saadc.c) from SDK 13 instead. I tested this whit your code, and it seems to solve the issue. I would also suggest that you enable burst mode in saadc_init() if using oversample, to avoid having to wait for multiple calls to nrf_drv_saadc_sample() to get one result:

channel_config.burst = NRF_SAADC_BURST_ENABLED;

Best regards,


edit flag offensive delete publish link more


Well done! It's OK now.

Alice ( 2017-07-18 14:44:06 +0200 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower


Asked: 2017-07-14 09:17:24 +0200

Seen: 60 times

Last updated: Jul 18