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

Sampling two analog signals using SAADC at two different rate

Hi,

I am working on one application in which I want to sample ECG at 1000 samples per second continuously and battery value at 15 seconds interval. I am configuring two channels of SAADC two do this task. but as there only one callback function I can have, I may loose any one signal samples after 15 seconds. I want Battery value to be samples at every 15 seconds and ECG continuously at 1000 samples per second.

How can achieve this task? Can anyone help me in this regards?

  • This is not trivial using the driver, so I will try to explain how it should work with the SAADC peripheral.

    You can enable or disable a channel by configuring the PSELP field, as the specification says:

    A channel is considered enabled if CH[n].PSELP is set. If more than one channel, CH[n], is enabled, the ADC enters scan mode.

    Enable the battery measurement channel every 15000 ECG sample and disable it when you have received the measurement.

    You also have to configure RESULT.MAXCNT to allow for two samples to be stored in RAM when you enable the battery measurement channel.

  • Hi,

    I have some questions about this.

    First we need to initialize all the channels yes in the ADC initialization as the example in the SDK!?

    Then we can enable or disable a specific channel using the following function:

    nrf_saadc_channel_pos_input_set(0, NRF_SAADC_INPUT_DISABLED); // to disable channel 0
        
        
    nrf_saadc_channel_pos_input_set(0, NRF_SAADC_INPUT_AIN0);  // to enable channel 0
    

    when I enable the channel using the above function while the ADC is running I will receive automatically the sample from this channel in the ADC callback ?

    Regarding the RESULT.MAXCNT, I don't need to change it since I initialized all the channels yes ? ( just after the initialization I disabled the channel I need to sample in less rate), or I still need to increase and decrease this parameter every time ?

    when channel 1 is enabled and channel 0 is disabled, I will receive the sample of channel 1 in the first index of the buffer or in the second !?

     

    Best Regards

    Jawad Khaleel

Related