<?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>Bluetooth Alarm Clock</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11984/bluetooth-alarm-clock</link><description>Hi, 
 I want to use nrf51 development board as a bluetooth alarm clock using internal RTC . How can I generate timestamps to determine current date and time. Can the timer library be used for this purpose?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 19 Feb 2016 11:50:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11984/bluetooth-alarm-clock" /><item><title>RE: Bluetooth Alarm Clock</title><link>https://devzone.nordicsemi.com/thread/45367?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2016 11:50:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b4a5dcc-2487-4c9e-99fb-8ee4b24844d1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;You can use the RTC directly, or you can use the application timer library. You would probably want to make the timer timeout at a regular interval, such as once every second, and calculate the current time based on that.&lt;/p&gt;
&lt;p&gt;Note that the accuracy your time depend on the 32 kHz clock source. If you use the internal RC and calibrate it every 4 seconds, the accuracy will be ±250 ppm. That means that the time can be off by as much as ±21.6 s per day, so it may not be accurate enough.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth Alarm Clock</title><link>https://devzone.nordicsemi.com/thread/45366?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2016 08:18:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bbc4b5d-0eea-4262-91b8-bbec8a73b576</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;&lt;strong&gt;Duplicate&lt;/strong&gt;: &lt;a href="https://devzone.nordicsemi.com/question/59881/i-want-to-implement-digital-clock-and-calender-in-nrf51422-using-internal-rtc/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Bluetooth Alarm Clock</title><link>https://devzone.nordicsemi.com/thread/45365?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2016 07:50:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c57a7dc-2e74-472b-920d-d1aaac805206</guid><dc:creator>BHAGYESH</dc:creator><description>&lt;p&gt;Digital clock and calendar along with nrf51422 and nrf51822 RTC&amp;#39;s setting.
BHAGYESH D BHAVASAR&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Internal 32kHz RC
NRF_CLOCK-&amp;gt;LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos;
// Start the 32 kHz clock, and wait for the start up to complete
NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART = 1;
while(NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0);

// Configure the RTC to run at 1 second intervals, and make sure COMPARE0 generates an interrupt (this will be the wakeup source)
NRF_RTC0-&amp;gt;PRESCALER = 0;
NRF_RTC0-&amp;gt;EVTENSET = RTC_EVTEN_COMPARE0_Msk; 
NRF_RTC0-&amp;gt;INTENSET = RTC_INTENSET_COMPARE0_Msk; 
// NORDIC: Count to 32767, and not 32768
NRF_RTC0-&amp;gt;CC[0] = 1*32767;

NVIC_EnableIRQ(RTC0_IRQn);
// NORDIC: SET IRQ PRIORITY
NVIC_SetPriority(RTC0_IRQn, 0);

NRF_RTC0-&amp;gt;TASKS_START = 1;

//--------------------------------------------------------------------------------------------------

void RTC0_IRQHandler(void)
{

	  // NORDIC: CLEAR TASK AS QUICKLY AS POSSIBLE
    NRF_RTC0-&amp;gt;TASKS_CLEAR = 1;
    // This handler will be run after wakeup from system ON (RTC wakeup)
    if(NRF_RTC0-&amp;gt;EVENTS_COMPARE[0])
    {
			  NRF_RTC0-&amp;gt;EVENTS_COMPARE[0] = 0;
		info.tm_sec++;
   
		}
}
//--------------------------------------------------------------------------------------------------
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>