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

nRF52 SAADC Continuous sampling

Hello Dev Zone.

thanks for watching mt ask.

I need help.

I have 2 question.

1. I need use saadc continuous sampling

in SDK example, is it continuous Mode?

it looks like simple tesk Mode call by timer int every time.

if i set saadc register like this

Fullscreen
1
2
3
4
5
// No automatic sampling, will trigger with TASKS_SAMPLE.
NRF_SAADC->SAMPLERATE = SAADC_SAMPLERATE_MODE_Timers << SAADC_SAMPLERATE_MODE_Pos;
// Sample Rate is 16 MHz / CC
// CC [80 ~ 2047] 200KHz ~ 7.816KHz
NRF_SAADC->SAMPLERATE |= 0x00000535;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
is it working continuous sampling also?
2. continuous sampling buffer set
if i use all saadc channel 0 to 7
Fullscreen
1
2
3
4
// Configure result to be put in RAM at the location of "result" variable.
NRF_SAADC->RESULT.MAXCNT = 8;
// uint16_t adc_sample
NRF_SAADC->RESULT.PTR = (uint32_t)&adc_sample;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 and uif i want to get data from ch no 4, 
 temp = adc_sample[4];
 can i use like that?
thanks for help
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//+add This is my full init Code for SAADC 0 - 7 Channel
for(uint8_t i = 0; i<8; i++)
{
// Configure SAADC singled-ended channel, Internal reference (0.6V) and 1/6 gain.
NRF_SAADC -> CH[i].CONFIG = (SAADC_CH_CONFIG_GAIN_Gain1_6 << SAADC_CH_CONFIG_GAIN_Pos) |
(SAADC_CH_CONFIG_MODE_SE << SAADC_CH_CONFIG_MODE_Pos) |
(SAADC_CH_CONFIG_REFSEL_Internal << SAADC_CH_CONFIG_REFSEL_Pos) |
(SAADC_CH_CONFIG_RESN_Bypass<< SAADC_CH_CONFIG_RESN_Pos)|
(SAADC_CH_CONFIG_RESP_Pulldown<< SAADC_CH_CONFIG_RESP_Pos)|
(SAADC_CH_CONFIG_TACQ_10us<< SAADC_CH_CONFIG_TACQ_Pos);
// Configure the SAADC channel with VDD as positive input, no negative input(single ended).
//NRF_SAADC->CH[i].PSELP = SAADC_CH_PSELP_PSELP_AnalogInput5 << SAADC_CH_PSELP_PSELP_Pos;
NRF_SAADC->CH[i].PSELP = (unsigned long) (i+1UL) << SAADC_CH_PSELP_PSELP_Pos;
NRF_SAADC->CH[i].PSELN = SAADC_CH_PSELN_PSELN_NC << SAADC_CH_PSELN_PSELN_Pos;
}
// Configure the SAADC resolution.
NRF_SAADC->RESOLUTION = SAADC_RESOLUTION_VAL_12bit << SAADC_RESOLUTION_VAL_Pos;
// Configure result to be put in RAM at the location of "result" variable.
NRF_SAADC->RESULT.MAXCNT =8;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX