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

SAADC clock source

Hello,

I developed an application on a BMD-300-EVAL. This is a evaluation platform with a BMD-300 module (nrf52832 chip + antenna + crystal +...) on it. The application uses the SAADC and the SoftDevice s132. The SAADC reads four channels with a sample rate of 1kHz (1ms). Every 40ms the SAADC readings get transmitted over NUS.

I was able to program a standalone BMD-300 module and my application runs on it after I made the following changes in the sdk_config.h regarding the clock source.

//==========================================================

// <h> Clock - SoftDevice clock configuration

//==========================================================
// <o> NRF_SDH_CLOCK_LF_SRC  - SoftDevice clock source.
 
// <0=> NRF_CLOCK_LF_SRC_RC 
// <1=> NRF_CLOCK_LF_SRC_XTAL 
// <2=> NRF_CLOCK_LF_SRC_SYNTH 

#ifndef NRF_SDH_CLOCK_LF_SRC
#define NRF_SDH_CLOCK_LF_SRC 0
#endif

// <o> NRF_SDH_CLOCK_LF_RC_CTIV - SoftDevice calibration timer interval. 
#ifndef NRF_SDH_CLOCK_LF_RC_CTIV
#define NRF_SDH_CLOCK_LF_RC_CTIV 16            
#endif

// <o> NRF_SDH_CLOCK_LF_RC_TEMP_CTIV - SoftDevice calibration timer interval under constant temperature. 
// <i> How often (in number of calibration intervals) the RC oscillator shall be calibrated
// <i>  if the temperature has not changed.

#ifndef NRF_SDH_CLOCK_LF_RC_TEMP_CTIV
#define NRF_SDH_CLOCK_LF_RC_TEMP_CTIV 0           
#endif

// <o> NRF_SDH_CLOCK_LF_ACCURACY  - External clock accuracy used in the LL to compute timing.
 
// <0=> NRF_CLOCK_LF_ACCURACY_250_PPM 
// <1=> NRF_CLOCK_LF_ACCURACY_500_PPM 
// <2=> NRF_CLOCK_LF_ACCURACY_150_PPM 
// <3=> NRF_CLOCK_LF_ACCURACY_100_PPM 
// <4=> NRF_CLOCK_LF_ACCURACY_75_PPM 
// <5=> NRF_CLOCK_LF_ACCURACY_50_PPM 
// <6=> NRF_CLOCK_LF_ACCURACY_30_PPM 
// <7=> NRF_CLOCK_LF_ACCURACY_20_PPM 
// <8=> NRF_CLOCK_LF_ACCURACY_10_PPM 
// <9=> NRF_CLOCK_LF_ACCURACY_5_PPM 
// <10=> NRF_CLOCK_LF_ACCURACY_2_PPM 
// <11=> NRF_CLOCK_LF_ACCURACY_1_PPM 

#ifndef NRF_SDH_CLOCK_LF_ACCURACY
#define NRF_SDH_CLOCK_LF_ACCURACY 1                   
#endif

Here comes my problem. In order to achieve a sampling rate of exactly 1kHz (1ms), I had to change the timer_config.frequency in saadc_sampling_event_init() from NRF_TIMER_FREQ_31250Hz to NRF_TIMER_FREQ_125kHz.

void saadc_sampling_event_init(void)
{
    ...
    timer_config.frequency = NRF_TIMER_FREQ_125kHz;
    ...
}

This change works well on the evaluation board. But on my standalone BMD-300 module it seems like that this change is not applied and I get the behaviour like timer_config.frequency is set to NRF_TIMER_FREQ_31250Hz. It looks like that it have something to do with the clock source. But I am not able to figure it out.

So I have the following questions:

1. Which clock source does the SAADC use by default?

2. What is the relation between the SAADC clock source and the SoftDevice clock source?

3. Do you have any suggestions how to solve this problem?

Thank you very much in advance.

Parents
  • The timers will use whatever clock source is currently running, so unless you have explicit started external HFCLK for instance, then it will run on the internal HFCLK by default. The internal HFCLK can be very inaccurate (e.g. several %), it's only by starting the external HFCLK that you will get a tolerance of <40ppm of the timers.

    I think you are mixing LFCLK and HFCLK here,  if you are using timers (it will use HFCLK), if you are using RTC (it will use LFCLK).

    Best regards,
    Kenneth

Reply
  • The timers will use whatever clock source is currently running, so unless you have explicit started external HFCLK for instance, then it will run on the internal HFCLK by default. The internal HFCLK can be very inaccurate (e.g. several %), it's only by starting the external HFCLK that you will get a tolerance of <40ppm of the timers.

    I think you are mixing LFCLK and HFCLK here,  if you are using timers (it will use HFCLK), if you are using RTC (it will use LFCLK).

    Best regards,
    Kenneth

Children
No Data
Related