Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PPI with multiple SAADCs and multiple TIMERs

Dear Nordic Support,

I am using PPI to link 2 timers (10ms & 5s) with 2 SAADC channel (AIN1 - channel 0 & AIN2 - channel 1). 

The nrf_drv_saadc_init function is only called once so it means there is only one callback for the sampling event. In case I am using 2 channels, how do I know that which channel has completed its sampling event in the callback function? When I printed out the ADC value, all I saw is CH0 and CH1 are read at the same time while I expect CH0 every 10ms and CH1 every 5s.

I am using nRF52840 + nRF5 SDK 15.3 + SD 6.1.1.

Thank you and best regards,

           Duy

            

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void saadc_transducer_callback(nrf_drv_saadc_evt_t const * p_event)
{
uint8_t idx;
if (p_event->type == NRF_DRV_SAADC_EVT_DONE)
{
APP_ERROR_CHECK(nrf_drv_saadc_buffer_convert(p_event->data.done.p_buffer, RAW_ADC_BUFF_SIZE));
NRF_LOG_INFO("T.ADC event number: %d", (int)m_transducer_evt_counter);
for (idx = 0; idx < RAW_ADC_BUFF_SIZE; idx++)
{
NRF_LOG_INFO("%d", p_event->data.done.p_buffer[idx]);
}
m_transducer_evt_counter++;
}
}
static void saadc_sampling_event_init(void)
{
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX