<?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>timer4 accuracy</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46014/timer4-accuracy</link><description>S in development environment ：Windows7 HARD :(Taiyo Yuden)EBSHSN Series Evaluation Board : Central / Peripherals CPU :(Nordic) nRF52832 / ARMR Cortex?-M4F 32 bit processor 28-pin Land Grid Array / 15GPIOs / SWD Soft Ver:nRF5_SDK_15.2.0_9412b96 clock </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Apr 2019 08:15:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46014/timer4-accuracy" /><item><title>RE: timer4 accuracy</title><link>https://devzone.nordicsemi.com/thread/183020?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 08:15:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:615d60ee-ac7f-4fce-ac9c-e894268e435e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You get &amp;quot;implicit declaration&amp;quot; errors for the clock driver functions you are calling. This is probably because you have forgotten to&amp;nbsp;include nrf_drv_clock.h in your main.c.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: timer4 accuracy</title><link>https://devzone.nordicsemi.com/thread/182789?ContentTypeID=1</link><pubDate>Fri, 19 Apr 2019 05:30:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5e96588-c575-4701-b95b-345f81fd7112</guid><dc:creator>yokokawa</dc:creator><description>&lt;pre class="tw-data-text tw-ta tw-text-small" dir="ltr"&gt;&lt;span lang="en"&gt;After confirming that the settings in &amp;quot;sdk_config.h&amp;quot; were as instructed and adding &amp;quot;static void clock_init (void)&amp;quot;,&lt;br /&gt; a warning was generated in &amp;quot;SEGGER_RTT_Syscalls_SES.C&amp;quot; because it was undefined.
Please tell me how to fix it.
I will attach a warning screen.
Thanking you in advance.&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/worning001.png" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/warning_5F00_02.png" /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="tw-data-text tw-ta tw-text-small" id="tw-target-text" dir="ltr"&gt;&lt;span lang="en"&gt;Postscript:
I use the following features
1) Peripheral wireless communication
2) AD conversion (2 channels)
3) Timer count
4) Key detection
No problem?&lt;/span&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: timer4 accuracy</title><link>https://devzone.nordicsemi.com/thread/182307?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 09:25:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb4eb6dd-f2ed-4cb4-806b-840fe399a80f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Let me just first say that you can test this most simply by one of the two other methods I mentioned (which depends on if you are using SoftDevice or not).&lt;/p&gt;
&lt;p&gt;For using the driver, you can refer to for instance the examples\802_15_4\wireless_uart example in SDK 15.2 to see the necessary files, includes and sdk_config.h parameters.&lt;/p&gt;
&lt;p&gt;Summing up:&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t have the clock driver configuration in your projects sdk_config.h, you should make sure to add it like this (adjust as needed):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// &amp;lt;e&amp;gt; NRF_CLOCK_ENABLED - nrf_drv_clock - CLOCK peripheral driver - legacy layer
//==========================================================
#ifndef NRF_CLOCK_ENABLED
#define NRF_CLOCK_ENABLED 1
#endif
// &amp;lt;o&amp;gt; CLOCK_CONFIG_LF_SRC  - LF Clock Source
 
// &amp;lt;0=&amp;gt; RC 
// &amp;lt;1=&amp;gt; XTAL 
// &amp;lt;2=&amp;gt; Synth 
// &amp;lt;131073=&amp;gt; External Low Swing 
// &amp;lt;196609=&amp;gt; External Full Swing 

#ifndef CLOCK_CONFIG_LF_SRC
#define CLOCK_CONFIG_LF_SRC 1
#endif

// &amp;lt;q&amp;gt; CLOCK_CONFIG_LF_CAL_ENABLED  - Calibration enable for LF Clock Source
 

#ifndef CLOCK_CONFIG_LF_CAL_ENABLED
#define CLOCK_CONFIG_LF_CAL_ENABLED 0
#endif

// &amp;lt;o&amp;gt; CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
 

// &amp;lt;i&amp;gt; Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
// &amp;lt;0=&amp;gt; 0 (highest) 
// &amp;lt;1=&amp;gt; 1 
// &amp;lt;2=&amp;gt; 2 
// &amp;lt;3=&amp;gt; 3 
// &amp;lt;4=&amp;gt; 4 
// &amp;lt;5=&amp;gt; 5 
// &amp;lt;6=&amp;gt; 6 
// &amp;lt;7=&amp;gt; 7 

#ifndef CLOCK_CONFIG_IRQ_PRIORITY
#define CLOCK_CONFIG_IRQ_PRIORITY 6
#endif
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The corresponding nrfx part will most likely already be there in your sdk_config.h, but if not, you should add this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//==========================================================
// &amp;lt;e&amp;gt; NRFX_CLOCK_ENABLED - nrfx_clock - CLOCK peripheral driver
//==========================================================
#ifndef NRFX_CLOCK_ENABLED
#define NRFX_CLOCK_ENABLED 1
#endif
// &amp;lt;o&amp;gt; NRFX_CLOCK_CONFIG_LF_SRC  - LF Clock Source
 
// &amp;lt;0=&amp;gt; RC 
// &amp;lt;1=&amp;gt; XTAL 
// &amp;lt;2=&amp;gt; Synth 
// &amp;lt;131073=&amp;gt; External Low Swing 
// &amp;lt;196609=&amp;gt; External Full Swing 

#ifndef NRFX_CLOCK_CONFIG_LF_SRC
#define NRFX_CLOCK_CONFIG_LF_SRC 1
#endif

// &amp;lt;o&amp;gt; NRFX_CLOCK_CONFIG_IRQ_PRIORITY  - Interrupt priority
 
// &amp;lt;0=&amp;gt; 0 (highest) 
// &amp;lt;1=&amp;gt; 1 
// &amp;lt;2=&amp;gt; 2 
// &amp;lt;3=&amp;gt; 3 
// &amp;lt;4=&amp;gt; 4 
// &amp;lt;5=&amp;gt; 5 
// &amp;lt;6=&amp;gt; 6 
// &amp;lt;7=&amp;gt; 7 

#ifndef NRFX_CLOCK_CONFIG_IRQ_PRIORITY
#define NRFX_CLOCK_CONFIG_IRQ_PRIORITY 6
#endif

// &amp;lt;e&amp;gt; NRFX_CLOCK_CONFIG_LOG_ENABLED - Enables logging in the module.
//==========================================================
#ifndef NRFX_CLOCK_CONFIG_LOG_ENABLED
#define NRFX_CLOCK_CONFIG_LOG_ENABLED 0
#endif
// &amp;lt;o&amp;gt; NRFX_CLOCK_CONFIG_LOG_LEVEL  - Default Severity level
 
// &amp;lt;0=&amp;gt; Off 
// &amp;lt;1=&amp;gt; Error 
// &amp;lt;2=&amp;gt; Warning 
// &amp;lt;3=&amp;gt; Info 
// &amp;lt;4=&amp;gt; Debug 

#ifndef NRFX_CLOCK_CONFIG_LOG_LEVEL
#define NRFX_CLOCK_CONFIG_LOG_LEVEL 3
#endif

// &amp;lt;o&amp;gt; NRFX_CLOCK_CONFIG_INFO_COLOR  - ANSI escape code prefix.
 
// &amp;lt;0=&amp;gt; Default 
// &amp;lt;1=&amp;gt; Black 
// &amp;lt;2=&amp;gt; Red 
// &amp;lt;3=&amp;gt; Green 
// &amp;lt;4=&amp;gt; Yellow 
// &amp;lt;5=&amp;gt; Blue 
// &amp;lt;6=&amp;gt; Magenta 
// &amp;lt;7=&amp;gt; Cyan 
// &amp;lt;8=&amp;gt; White 

#ifndef NRFX_CLOCK_CONFIG_INFO_COLOR
#define NRFX_CLOCK_CONFIG_INFO_COLOR 0
#endif

// &amp;lt;o&amp;gt; NRFX_CLOCK_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
 
// &amp;lt;0=&amp;gt; Default 
// &amp;lt;1=&amp;gt; Black 
// &amp;lt;2=&amp;gt; Red 
// &amp;lt;3=&amp;gt; Green 
// &amp;lt;4=&amp;gt; Yellow 
// &amp;lt;5=&amp;gt; Blue 
// &amp;lt;6=&amp;gt; Magenta 
// &amp;lt;7=&amp;gt; Cyan 
// &amp;lt;8=&amp;gt; White 

#ifndef NRFX_CLOCK_CONFIG_DEBUG_COLOR
#define NRFX_CLOCK_CONFIG_DEBUG_COLOR 0
#endif

// &amp;lt;/e&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then make a function like this and call it from your main function where you initialize the system (after enabling the SoftDevice if it is being used):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void clock_init(void)
{
    ret_code_t err_code = nrf_drv_clock_init();
    ASSERT((err_code == NRF_SUCCESS) || (err_code == NRF_ERROR_MODULE_ALREADY_INITIALIZED));

    nrf_drv_clock_hfclk_request(NULL);
    while (!nrf_drv_clock_hfclk_is_running())
    {
        // spin lock
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Br,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: timer4 accuracy</title><link>https://devzone.nordicsemi.com/thread/182298?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 08:54:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70b4f0e0-9a82-40df-a0bb-034d77a160d4</guid><dc:creator>yokokawa</dc:creator><description>&lt;p&gt;I am using the SDK. &lt;br /&gt;Please give a sample program using &amp;quot;nrf_drv_clock_hfclk_request ()&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: timer4 accuracy</title><link>https://devzone.nordicsemi.com/thread/182227?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 05:33:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:187c76d6-0515-4b9e-9435-17e786137ee3</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;there seems to be a misunderstanding here. The TIMER peripherals use the HF clock, so it has nothing to do with the 32.768 kHz oscillator.&amp;nbsp;The timer will use the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/clock.html?cp=3_1_0_18_0#concept_rp5_fgp_bs"&gt;HFCLK&lt;/a&gt;, which use a HFINT (RC) or &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/clock.html?cp=3_1_0_18_0_0#concept_rmw_c5y_2q"&gt;HFXO&lt;/a&gt;&amp;nbsp;(32 MHz crystal) as reference. So to get an accurate TIMER, you nee to enable the HFXO.&lt;/p&gt;
&lt;p&gt;If you are testing without a SoftDevice, then you can simply enable it like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART    = 1;

    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
    {
        // Do nothing while waiting for the clock to start
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you are using a SoftDevice you should call &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v6.1.0/group___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html?cp=3_4_1_2_2_7_2_3#ga3e5afb495a1b0307c749cc268df94a74"&gt;sd_clock_hfclk_request()&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In the end, if you want to make a clean solution that works with all other SDK drivers and libraries you should use the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/hardware_driver_clock.html?cp=5_0_2_0_0"&gt;clock driver&lt;/a&gt;&amp;nbsp;and call &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__drv__clock.html?cp=5_0_6_9_0_3_0_8#ga425c8dc0508bb9c0777da123b7c66f3d"&gt;nrf_drv_clock_hfclk_request()&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: timer4 accuracy</title><link>https://devzone.nordicsemi.com/thread/182217?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2019 02:13:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52772eae-cf23-4e65-93ec-9412cb143b29</guid><dc:creator>yokokawa</dc:creator><description>&lt;p&gt;I switched from the CR oscillator (HFINT) to the 32.768 kHz crystal oscillator (HFXO) and checked the operation, but it was not synchronized.&lt;br /&gt;The contents of the timer settings will be attached, so please point out the mistake.&lt;br /&gt;Thank you very much.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/SAMPLE.c"&gt;devzone.nordicsemi.com/.../SAMPLE.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: timer4 accuracy</title><link>https://devzone.nordicsemi.com/thread/181323?ContentTypeID=1</link><pubDate>Wed, 10 Apr 2019 12:21:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9166e50d-74ed-49c5-98aa-4bdf125eac5e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Assuming you have no problem with your SW implementation, the accuracy of the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/timer.html?cp=2_1_0_23#concept_xbd_hqp_sr"&gt;timer&lt;/a&gt; is given by the accuracy of the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/clock.html?cp=2_1_0_18_0#concept_rp5_fgp_bs"&gt;HF clock&lt;/a&gt;, which&amp;nbsp; is given by the clock source. If you use the&amp;nbsp;internal RC&amp;nbsp;oscillator (&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/clock.html?cp=2_1_0_18_3_0#unique_1861058799"&gt;HFINT&lt;/a&gt;), the accuracy is at worst&amp;nbsp;&amp;lt;±6 %. In other words very inaccurate, so you should always use the crystal oscillator (&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/clock.html?cp=2_1_0_18_3_1#unique_1749008215"&gt;HFXO&lt;/a&gt;) when you need a decent accuracy. In that case the accuracy is given by the accuracy of the crystal you are using.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>