<?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>some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/1339/some-question-of-nrf51822-timer</link><description>I am developing using a nrf51822.I need delay timer
that can be substitued for nrf_delay_ms().
in other words,need a task delay that can be taken some event from another side during delay time.
Is nrf_timer_delay_ms() possible ?
If so,please tell</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 27 Oct 2015 07:42:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/1339/some-question-of-nrf51822-timer" /><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6104?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2015 07:42:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f6f2251-5b99-45e4-abe3-31be9df13bcb</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I suspect this example is implemented for SDK 6.1.
Perhaps you can use the timer examples in the &lt;a href="http://developer.nordicsemi.com/nRF51_SDK/"&gt;nRF51 SDK&lt;/a&gt;, i.e. either the &amp;quot;timer&amp;quot; example or the &amp;quot;simple timer&amp;quot; example, which should provide similar functionality. These examples should be available for SDK 8 also.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6103?ContentTypeID=1</link><pubDate>Mon, 26 Oct 2015 11:40:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e00e56d6-c120-44f4-942f-6fd432874695</guid><dc:creator>vineeshvs</dc:creator><description>&lt;p&gt;When I try to use this project using the resources available in SDK8 in Keil, I am getting an error saying that file is missing&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;quot;no source&amp;quot;: Error:  #5: cannot open source input file &amp;quot;..\..\..\..\..\bsp\bsp_btn_ble.c&amp;quot;: No such file or directory
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Which SDK is the project &lt;strong&gt;timer_example_timer_mode.zip&lt;/strong&gt; based on&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6112?ContentTypeID=1</link><pubDate>Tue, 13 May 2014 11:17:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8be9e76f-0a84-4915-b9c9-085888500b54</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Here&amp;#39;s my best guess. Not tested:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
#include &amp;lt;nrf51_bitfields.h&amp;gt;
#include &amp;lt;nrf51.h&amp;gt;

#define LFCLK_FREQUENCY           (32768UL)                               /**&amp;lt; LFCLK frequency in Hertz, constant. */

// The attribute constructor ensures this runs before main.
void initClock() __attribute__((constructor));

void initClock()
{
	NRF_CLOCK-&amp;gt;LFCLKSRC             = (CLOCK_LFCLKSRC_SRC_Synth &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos);
	NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED  = 0;
	NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART     = 1;
	while (NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0)
	{
	}
}

/** @brief Function for configuring the RTC with TICK to 100Hz and COMPARE0 to 10 sec.
 */
void sleepDelay(uint32_t ms)
{
	// We use RTC1 since RTC0 is controlled by the soft device.

	// Enable interrupt.
	NVIC_EnableIRQ(RTC1_IRQn);

	// Find the minimum prescalar for this delay.
	//
	// Freq = 32768 Hz / (PRESCALAR + 1)
	//
	// RTC1 has a 24 bit counter.
	//
	// So we want 0xFFFFFF / Freq &amp;gt; ms
	// =&amp;gt;   PRESCALAR &amp;gt; ms * 32768 / 0xFFFFFF - 1
	//
	// PRESCALAR is in the range 0 to 2^12-1.

	NRF_RTC1-&amp;gt;PRESCALER     = ms * LFCLK_FREQUENCY / 0xFFFFFFUL;
	NRF_RTC1-&amp;gt;CC[0]         = ms * LFCLK_FREQUENCY / (NRF_RTC1-&amp;gt;PRESCALER + 1);

	// Enable COMPARE0 event and COMPARE0 interrupt:
	NRF_RTC1-&amp;gt;EVTENSET      = RTC_EVTENSET_COMPARE0_Msk;
	NRF_RTC1-&amp;gt;INTENSET      = RTC_INTENSET_COMPARE0_Msk;

	NRF_RTC1-&amp;gt;TASKS_CLEAR = 1;
	NRF_RTC1-&amp;gt;TASKS_START = 1;

	// Wait For Event.
	// This wakes up when any interrupt is fired so it is possible that the delay will not be as long as requested.
	__WFE();
}

/** @brief: Function for handling the RTC0 interrupts.
 * Triggered on TICK and COMPARE0 match.
 */
void RTC1_IRQHandler()
{
	if ((NRF_RTC1-&amp;gt;EVENTS_COMPARE[0] != 0) &amp;amp;&amp;amp; ((NRF_RTC1-&amp;gt;INTENSET &amp;amp; RTC_INTENSET_COMPARE0_Msk) != 0))
	{
		NRF_RTC1-&amp;gt;EVENTS_COMPARE[0] = 0;
		NRF_RTC1-&amp;gt;INTENSET = 0;
		NRF_RTC1-&amp;gt;TASKS_STOP = 1;
	}
}

&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6111?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2014 10:58:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c6c7022-fbfc-4520-acbd-4f2b852dda17</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;I&amp;#39;d strongly recommend you to rework your code so that you don&amp;#39;t rely on a precise delay mechanism, but instead use app_timer to trigger tasks with the intervals you need. This will give you a much more robust solution, especially when taking into account the different interrupts that will all affect delay loops.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6110?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2014 03:46:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d31b213c-93f6-4d57-891f-d9e7e1cd305c</guid><dc:creator>hjjeon</dc:creator><description>&lt;p&gt;I seems to find the good solution.
I use app timer and app timer use the rtc1 timer.
so I made the delay like below.
void nrf_delay_ms(uint32_t volatile number_of_ms)
{
while(number_of_ms != 0)
{&lt;/p&gt;
&lt;p&gt;number_of_ms--;
#if 1
for(uint8_t i=0;i&amp;lt;30;i++)
{
RTC1_IRQHandler();
nrf_delay_us(30);
}
#else
nrf_delay_us(999);
#endif
}
}
because RTC1_IRQHandler will be expired every 31us.
32khz = 31us.
Could you inspect my code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6109?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2014 03:22:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b5c901b-1cd4-4ccb-ab40-7b8e8aa9c32f</guid><dc:creator>hjjeon</dc:creator><description>&lt;p&gt;the timer event that i have to get during delay,is app timer(rtc1 timer) expire event for calling the handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6108?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2014 02:34:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dfcb1be-ffd4-45bf-9534-125c8a998a32</guid><dc:creator>hjjeon</dc:creator><description>&lt;p&gt;I made like below.Please review my code which one is the best for taking another timer event during delay.or if it&amp;#39;s wrong, inform me.&lt;/p&gt;
&lt;p&gt;void nrf_delay_ms(uint32_t volatile number_of_ms)
{
while(number_of_ms != 0)
{
__WFE();
__SEV();
__WFE();
number_of_ms--;
nrf_delay_us(999);
}
}&lt;/p&gt;
&lt;p&gt;void nrf_delay_ms(uint32_t volatile number_of_ms)
{
while(number_of_ms != 0)
{
__WFI();
number_of_ms--;
nrf_delay_us(999);
}
}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6107?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2014 08:52:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2edb16dc-0dec-4f00-a792-85966fc3f693</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi hjjeon&lt;/p&gt;
&lt;p&gt;If you want to sleep during your delay instead of executing code, in order to save power, you can do the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set up your TIMER interrupt with the desired delay and enable the interrupt.&lt;/li&gt;
&lt;li&gt;When you want a delay, start the timer and go to sleep with the __WFI command (see nRF51 Series Reference Manual (RM) v2.1, section 11.1.3.&lt;/li&gt;
&lt;li&gt;When the timer expires, it will generate an interrupt, the chip will wake up and execute your defined interrupt handler.&lt;/li&gt;
&lt;li&gt;The TIMER interrupt handler stops the TIMER and resets it, making the TIMER counter to be zero.&lt;/li&gt;
&lt;li&gt;When the interrupt handler finishes execution, code execution will continue in the main thread, starting with the command after your __WFI command.&lt;/li&gt;
&lt;li&gt;Whenever you want a delay again in your code execution, simply start the timer and issue __WFI command.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6106?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2014 05:11:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd644e34-9d79-45fa-bf18-0d835cf322e8</guid><dc:creator>hjjeon</dc:creator><description>&lt;p&gt;I can use the timer .but All i need is time delay function.
I can&amp;#39;t make this using a timer caused by my stupid.
Could you help me?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6105?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2014 08:19:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ab17ee2-09f3-4976-8946-dd3c7a5bf201</guid><dc:creator>hjjeon</dc:creator><description>&lt;p&gt;thank you for your consideration&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: some question of nrf51822 timer</title><link>https://devzone.nordicsemi.com/thread/6102?ContentTypeID=1</link><pubDate>Tue, 14 Jan 2014 08:20:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a916535d-d108-4b71-b34d-4b95bfa621ff</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi hjjeon&lt;/p&gt;
&lt;p&gt;There are two kinds of hardware timers, TIMER and RTC. TIMERs can generate events with up to 16MHz frequency while the RTC timer can generate events with up to 32 kHz frequency. Benefit of using RTC is that it is power efficient.&lt;/p&gt;
&lt;p&gt;I attach a TIMER example that uses the TIMER interrupt. While waiting for the TIMER interrupt, you can use the CPU to perform other tasks.&lt;/p&gt;
&lt;p&gt;If you are interrested in using the RTC timer, take a look at the rtc_example in the nRF51822 SDK which uses RTC interrupt.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/timer_5F00_example_5F00_timer_5F00_mode.zip"&gt;timer_example_timer_mode.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>