<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SAADC - Real sample rate is a bit higher than the configured sample rate</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66819/saadc---real-sample-rate-is-a-bit-higher-than-the-configured-sample-rate</link><description>Hello, 
 in my project I have a custom board with a nRF52832 chip, which reads 4 channels with a sample rate of 1kHz (1ms). The SAADC readings get transmitted to a nRF52840DK via NUS every 40ms. Overall, this setup works fine and I receive the right SAADC</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Oct 2020 06:31:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66819/saadc---real-sample-rate-is-a-bit-higher-than-the-configured-sample-rate" /><item><title>RE: SAADC - Real sample rate is a bit higher than the configured sample rate</title><link>https://devzone.nordicsemi.com/thread/273918?ContentTypeID=1</link><pubDate>Fri, 09 Oct 2020 06:31:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:229e2784-8aba-479d-9705-0c4a72d0c1b1</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Thank you very much for your reply.&lt;/p&gt;
&lt;p&gt;I will keep that in mind.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC - Real sample rate is a bit higher than the configured sample rate</title><link>https://devzone.nordicsemi.com/thread/273838?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 15:16:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4f471c1-d60b-4c6a-852b-b16cd9199201</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;You can call hfclk request from anywhere, before starting timer is preferred though. If you want low power you should use rtc (running from lfclk) instead of timer (running from hfclk), but then that will affect the accuracy.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC - Real sample rate is a bit higher than the configured sample rate</title><link>https://devzone.nordicsemi.com/thread/273626?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 06:41:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd0dfb22-c911-495b-991b-4056053cd9ee</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Hello Kenneth,&lt;/p&gt;
&lt;p&gt;thank you very much for your response.&lt;/p&gt;
&lt;p&gt;I added this request into my&amp;nbsp;saadc_sampling_event_init(void) function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void saadc_sampling_event_init(void)
{
    ret_code_t err_code;
    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);
    
    nrf_drv_timer_config_t timer_config = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_config.frequency = NRF_TIMER_FREQ_125kHz;                                                             
    err_code = nrf_drv_timer_init(&amp;amp;m_timer, &amp;amp;timer_config, timer_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_clock_hfclk_request(NULL);

    /* setup m_timer for compare event */
    uint32_t ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer,SAADC_SAMPLE_RATE);
    nrf_drv_timer_extended_compare(&amp;amp;m_timer, NRF_TIMER_CC_CHANNEL0, ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
    nrf_drv_timer_enable(&amp;amp;m_timer);
    
    ...
    
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It looks like, this fixed my problem. Thank you for that. It seems that the&amp;nbsp;&lt;span&gt;HFCLK&amp;nbsp;consumes about 150&amp;micro;A.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you recommend to call&amp;nbsp;nrf_drv_clock_hfclk_request(NULL) in the&amp;nbsp;saadc_sampling_event_init(void) function or somewhere else?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you in advance.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Michael&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC - Real sample rate is a bit higher than the configured sample rate</title><link>https://devzone.nordicsemi.com/thread/273615?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 06:07:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c65c86d5-69a5-4267-985b-4469bac7e39b</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Can you try to start the HFCLK here by&amp;nbsp;&lt;span&gt;nrf_drv_clock_hfclk_request&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;NULL&lt;/span&gt;&lt;span&gt;). The internal HFCLK is not accurate (typical 1-2% tolerance).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC - Real sample rate is a bit higher than the configured sample rate</title><link>https://devzone.nordicsemi.com/thread/273509?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 13:23:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f112dd88-4162-46bc-88cb-2d5e3833db95</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I was able to fix the problem for my nrf52832 on my development board. It works just fine there.&lt;/p&gt;
&lt;p&gt;But on my custom board with the nrf52832 chip it does not work. Maybe it has something to do with the timer source. On the custom board, the SoftDevice uses&amp;nbsp;NRF_CLOCK_LF_SRC_RC instead of&amp;nbsp;NRF_CLOCK_LF_SRC_XTAL.&lt;/p&gt;
&lt;p&gt;Here are my questions:&lt;/p&gt;
&lt;p&gt;1. Is this a problem of the timer source?&lt;/p&gt;
&lt;p&gt;2. Which timer does the SAADC use by default?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you so much in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC - Real sample rate is a bit higher than the configured sample rate</title><link>https://devzone.nordicsemi.com/thread/273470?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 11:27:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89786c67-84eb-4431-9b12-e3f8f1d2d2b6</guid><dc:creator>Michael01101</dc:creator><description>&lt;p&gt;Hello Turbo J,&lt;/p&gt;
&lt;p&gt;thank you very much for your fast reply.&lt;/p&gt;
&lt;p&gt;It looks like you fixed my problem.&lt;/p&gt;
&lt;p&gt;I wish you a great day. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC - Real sample rate is a bit higher than the configured sample rate</title><link>https://devzone.nordicsemi.com/thread/273463?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 11:15:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88c5d8e6-ea10-480f-8d7a-bde0b0158a1d</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Relevant code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;timer_config.frequency = NRF_TIMER_FREQ_31250Hz; &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That frequency has no available integer divider in order to achieve exactly 1 kHz.&lt;/p&gt;
&lt;p&gt;Just use NRF_TIMER_FREQ_125kHz or higher.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>