<?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>how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/219/how-can-i-make-system-tick-funtion</link><description>I know that nrf51822 is not supported system tick handler ?
I need system tick function.
How can i make system tick function for nrf51822?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Aug 2013 09:21:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/219/how-can-i-make-system-tick-funtion" /><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1229?ContentTypeID=1</link><pubDate>Wed, 21 Aug 2013 09:21:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:319d3802-803b-4c15-8c9e-149dbbb41806</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry, but I still have serious problems understanding what you want. If you want a TICK with a frequency of 32.768 kHz, you should just use the RTC. You will not get a precise 32.768 kHz tick by using the 16 MHz timers. If you want a tick for every 1 ms, you have to use one of the 16 MHz timers, and do as I said in this initial answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1230?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2013 10:51:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b821666f-3805-492d-8d28-cd5021b131aa</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;@Ole
I&amp;#39;m sorry for making a confusion to you.
I made code like to below for using 16Mhz system clock.&lt;/p&gt;
&lt;p&gt;/* Start 16 MHz crystal oscillator */
NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;			NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;			&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/* Wait for the external oscillator to start up */
while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)		
{
}
NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;		
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;after this routine, I would like to configure 1ms tick timer.
I think that the 1ms tick timer seem to be made using timer interrupt(timerX_IRQn). So, Can I make the tick timer using 32.768Hz with system clock 16MHz? If this is possible, How can I make code?&lt;/p&gt;
&lt;p&gt;I look forward to wait for your detailed guide.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1228?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2013 10:51:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db660ec2-59d3-4643-b20c-0c5a1fb19d9d</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;@Ole
I&amp;#39;m sorry for making a confusion to you.
I made code like to below for using 16Mhz system clock.&lt;/p&gt;
&lt;p&gt;/* Start 16 MHz crystal oscillator */
NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;			NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;			&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/* Wait for the external oscillator to start up */
while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)		
{
}
NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;		
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;after this routine, I would like to configure 1ms tick timer.
I think that the 1ms tick timer seem to be made using timer interrupt(timerX_IRQn). So, Can I make the tick timer using 32.768Hz with system clock 16MHz? If this is possible, How can I make code?&lt;/p&gt;
&lt;p&gt;I look forward to wait for your detailed guide.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1227?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2013 07:21:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4063331-3bfb-4bc2-80bc-702118c29de9</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;I&amp;#39;m not quite sure I understand your question correctly, but no matter what clock source you use, the MCU will run on 16 MHz. Could you perhaps explain a little more if you have further questions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1226?ContentTypeID=1</link><pubDate>Sat, 17 Aug 2013 13:34:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdd24669-cb61-40f5-931c-bd3f7d88fb9a</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;@Ole
As you are comment, I have to 16Mhz osc for accurate 1ms tick.
currently, my system is using a system clock 16MHz.
For using RTC1,
Is the system clock set 32.768KHz?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1231?ContentTypeID=1</link><pubDate>Sat, 17 Aug 2013 13:34:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3268aa9c-2442-4077-bfdc-e5722e5c41ff</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;@Ole
As you are comment, I have to 16Mhz osc for accurate 1ms tick.
currently, my system is using a system clock 16MHz.
For using RTC1,
Is the system clock set 32.768KHz?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1218?ContentTypeID=1</link><pubDate>Sat, 17 Aug 2013 13:23:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15b070f8-7fe8-4beb-bce8-9c05da878e90</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;@philip,
Thank you for your help.
that&amp;#39;s work it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1219?ContentTypeID=1</link><pubDate>Sat, 17 Aug 2013 13:23:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f144e445-aabd-43bc-9ca6-dbaff8108d6c</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;@philip,
Thank you for your help.
that&amp;#39;s work it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1217?ContentTypeID=1</link><pubDate>Sat, 17 Aug 2013 01:49:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:936f0aa5-7f9c-4231-a7bb-6f3f843447a8</guid><dc:creator>Philip Freidin</dc:creator><description>&lt;p&gt;Those #defines are in nrf51_bitfields.h&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1216?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2013 21:38:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:986ea251-8de6-4c9e-84f5-b6a1f554a2b6</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;@philips,
where can I find the below variables?
CLOCK_LFCLKSRC_SRC_RC,
CLOCK_LFCLKSRC_SRC_Pos,
RTC_EVTENSET_TICK_Enabled,
RTC_EVTENSET_TICK_Pos,
RTC_INTENSET_TICK_Enabled
and RTC_INTENSET_TICK_Pos.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1220?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2013 21:38:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42f9a48e-9d56-4e22-819b-c0e8493ac060</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;@philips,
where can I find the below variables?
CLOCK_LFCLKSRC_SRC_RC,
CLOCK_LFCLKSRC_SRC_Pos,
RTC_EVTENSET_TICK_Enabled,
RTC_EVTENSET_TICK_Pos,
RTC_INTENSET_TICK_Enabled
and RTC_INTENSET_TICK_Pos.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1215?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2013 11:13:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee904b86-84f3-4447-94de-873124e28027</guid><dc:creator>Philip Freidin</dc:creator><description>&lt;p&gt;Do not replace nrf51.h , you need it.&lt;/p&gt;
&lt;p&gt;Replace the #include &amp;quot;nrf51_PF_Lib.h&amp;quot; with this:&lt;/p&gt;
&lt;p&gt;extern uint32_t RTC1_Milliseconds;
extern uint32_t RTC1_Seconds;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1214?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2013 10:22:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50bccd1a-0c6a-47fb-8f04-fb67238e618a</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;@Philip
As you inform to me,
I saw RTC1_ms_timer.c registering on thread that you link.
but, I don&amp;#39;t have head file, nRF51_PF_Lib.h.
Is this header same as nrf51.h file?&lt;/p&gt;
&lt;p&gt;Altough I replace nrf51_PF_Lib.h to nrf51.h,
the compiler don&amp;#39;t find follow define variables :
CLOCK_LFCLKSRC_SRC_RC,
CLOCK_LFCLKSRC_SRC_Pos,
RTC_EVTENSET_TICK_Enabled,
RTC_EVTENSET_TICK_Pos,
RTC_INTENSET_TICK_Enabled
and RTC_INTENSET_TICK_Pos.&lt;/p&gt;
&lt;p&gt;Where can these be finded?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1221?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2013 10:22:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a61bc11-ecb2-4830-90bd-be05eb214b82</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;@Philip
As you inform to me,
I saw RTC1_ms_timer.c registering on thread that you link.
but, I don&amp;#39;t have head file, nRF51_PF_Lib.h.
Is this header same as nrf51.h file?&lt;/p&gt;
&lt;p&gt;Altough I replace nrf51_PF_Lib.h to nrf51.h,
the compiler don&amp;#39;t find follow define variables :
CLOCK_LFCLKSRC_SRC_RC,
CLOCK_LFCLKSRC_SRC_Pos,
RTC_EVTENSET_TICK_Enabled,
RTC_EVTENSET_TICK_Pos,
RTC_INTENSET_TICK_Enabled
and RTC_INTENSET_TICK_Pos.&lt;/p&gt;
&lt;p&gt;Where can these be finded?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1225?ContentTypeID=1</link><pubDate>Tue, 06 Aug 2013 04:32:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb2815ae-bcf0-4dfc-9042-2b26a7a10982</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;Remember that a 16 MHz crystal is required for radio operation. However, timers can also run on the internal 16 MHz RC oscillator.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d also be happy if you could accept one of the answers, to clear up the discussion. :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1222?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2013 21:01:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c99cb01-7f35-4ebb-95b2-fc5cef329611</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;Thank you for  your code.
I will check the  code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1213?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2013 21:01:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c054a05-6c75-47a7-a451-486c653884ff</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;Thank you for  your code.
I will check the  code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1224?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2013 20:58:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c07c804-0576-459f-ab84-73f0f2439f3f</guid><dc:creator>Bastiaan</dc:creator><description>&lt;p&gt;Thank you for your detailed explanation.
I will  check whether  there  is 16Mhz  crystal  in my  module.
If  there is it, I will  try  your comment.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1232?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2013 20:58:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e61c704-7d2f-457b-b0e2-59027c352153</guid><dc:creator>Guest</dc:creator><description>&lt;p&gt;Thank you for your detailed explanation.
I will  check whether  there  is 16Mhz  crystal  in my  module.
If  there is it, I will  try  your comment.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1223?ContentTypeID=1</link><pubDate>Mon, 05 Aug 2013 05:50:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2de7dda-95a0-453c-819c-57774a9d7345</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;If you need exactly 1 ms ticks, you will have to use the 16 MHz timers, since the low-frequency clock is 32.768 kHz (32768 Hz), giving ticks with a frequency of &lt;a href="https://www.google.no/search?client=opera&amp;amp;rls=en&amp;amp;q=(32768/1000)-1&amp;amp;sourceid=opera&amp;amp;ie=utf-8&amp;amp;oe=utf-8&amp;amp;channel=suggest#client=opera&amp;amp;hs=wUb&amp;amp;rls=en&amp;amp;channel=suggest&amp;amp;sclient=psy-ab&amp;amp;q=32768%2F(32%2B1)&amp;amp;oq=&amp;amp;gs_l=&amp;amp;pbx=1&amp;amp;bav=on.2,or.r_qf.&amp;amp;bvm=bv.50165853,d.bGE&amp;amp;fp=938bfbe94e6350d9&amp;amp;biw=1887&amp;amp;bih=1116&amp;amp;pf=p&amp;amp;pdl=300"&gt;32768/(32+1) = 992.96... Hz&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The 16 MHz timers does not have a TICK interrupt, so to use them for such purpose, I&amp;#39;d recommend to set the PRESCALER register to something appropriate, set one of the CC values correctly and enable the COMPAREX_CLEAR shortcut, so that the timer restarts on each compare. After this, you can enable the COMPAREX interrupt in INTEN and the TIMERX interrupt in the NVIC, and then just start the TIMER and let it run.&lt;/p&gt;
&lt;p&gt;For completeness, making a tick is easier with the RTC; you just set the PRESCALER correctly, enable the TICK interrupt in INTEN and the RTC interrupt in the NVIC and then start the RTC. Remember to start the LFCLK before starting the RTC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how can i make system tick funtion?</title><link>https://devzone.nordicsemi.com/thread/1212?ContentTypeID=1</link><pubDate>Sun, 04 Aug 2013 16:02:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b94a46f5-22eb-47eb-8854-31b7d8e698ee</guid><dc:creator>Philip Freidin</dc:creator><description>&lt;p&gt;I have posted some code in my answer to this thread. It implements a 1 ms tick using RTC1.
Maybe this will meet your needs.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;**[comprehension-question-timer](&lt;a href="https://devzone.nordicsemi.com/index.php/discussions/comprehension-question-timer)**"&gt;devzone.nordicsemi.com/.../comprehension-question-timer)**&lt;/a&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>