<?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 to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21402/how-to-call-time-function-in-nordic-nrf518222-milliseconds</link><description>Hello, 
 Please tell me, How to call Time() in milliseconds in Nordic nrf51822 ??</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 10 Nov 2020 08:39:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21402/how-to-call-time-function-in-nordic-nrf518222-milliseconds" /><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/279140?ContentTypeID=1</link><pubDate>Tue, 10 Nov 2020 08:39:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dce0780b-5260-42c7-86cb-b47695c75b1e</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Not sure what you mean. Both me and my colleague Simon&amp;nbsp;have responded to other cases where you post the same question?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/278981?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 11:39:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62527caa-f38a-4e23-9bc4-86e4350e6a63</guid><dc:creator>manikandan</dc:creator><description>&lt;p&gt;no one responding to my recent post thats why i asked here can u clarify about my doubt about milliseconds&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/278964?ContentTypeID=1</link><pubDate>Mon, 09 Nov 2020 10:28:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8391224-a60b-4111-9ff5-9c24efba3c40</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which code are you referring to?&lt;/p&gt;
&lt;p&gt;In general I would recommend opening a new case rather than responding to one that is several years old &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/278859?ContentTypeID=1</link><pubDate>Fri, 06 Nov 2020 21:25:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14e078d9-7654-4200-bdd3-8ce2076d7929</guid><dc:creator>manikandan</dc:creator><description>&lt;p&gt;above code use rtc or not??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/125435?ContentTypeID=1</link><pubDate>Thu, 22 Mar 2018 02:39:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6edfce89-2821-41e4-8397-c4f0812da4dc</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;If you click on the &amp;quot;All Terminals&amp;quot; tab, do you see some output then?&lt;/p&gt;
&lt;p&gt;The &amp;quot;Log&amp;quot; tab will only show RTT log information, not the actual output from the Nordic kit.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/124909?ContentTypeID=1</link><pubDate>Mon, 19 Mar 2018 07:55:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c126ce87-610c-4808-8544-2455b5bbd88d</guid><dc:creator>Rachit</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I tried your solution but I&amp;#39;m unable to get past the following screen whose screenshot is attached along with this. Thank you&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/2781.RTT.JPG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/124614?ContentTypeID=1</link><pubDate>Thu, 15 Mar 2018 14:19:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6584ae51-c0f1-4fa5-9da7-9723bb788664</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you running the J-Link RTT Viewer software on your PC?&lt;/p&gt;
&lt;p&gt;Then you should see all the output from the devkit, as long as the code is running and the kit is connected to the PC over USB.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/124533?ContentTypeID=1</link><pubDate>Thu, 15 Mar 2018 09:32:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a8c5bbd-593a-4bf7-88d8-bd64f68ea9ef</guid><dc:creator>Rachit</dc:creator><description>&lt;p&gt;Hi! Sorry for replying to you late but I am unable to verify the results of the code in the logger or probably I&amp;#39;m not observing the results in the right place. Could you help me out since I&amp;#39;m new to this module. &amp;nbsp; &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/123461?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 14:39:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c206437-952a-4659-9c9b-1acf68d41030</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;If you are using the log module you can print&amp;nbsp;integer numbers in a similar way to the printf function, so you could do something like this:&lt;/p&gt;
&lt;p&gt;NRF_LOG_INFO(&amp;quot;Time in milliseconds: %i&amp;quot;, (int)&lt;code&gt;my_timer_get_ms()&lt;/code&gt;);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/123340?ContentTypeID=1</link><pubDate>Thu, 08 Mar 2018 06:08:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0df42de9-8046-467a-8338-d48320208ee5</guid><dc:creator>Rachit</dc:creator><description>&lt;p&gt;I am using the nrf_log group in the project if that is what you meant. Check the image below if that is of any help.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/4403.Capture5.JPG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/123224?ContentTypeID=1</link><pubDate>Wed, 07 Mar 2018 11:45:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3be08a2-d65e-485d-a4fc-dbb0f2bf16e1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Are you using the nrf_log module?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/123022?ContentTypeID=1</link><pubDate>Tue, 06 Mar 2018 10:43:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26d20bb5-3251-4ee8-b722-483276d4683b</guid><dc:creator>Rachit</dc:creator><description>&lt;p&gt;Could you also help me in understanding how do I print the time(with millisecond accuracy) on uart terminal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/123001?ContentTypeID=1</link><pubDate>Tue, 06 Mar 2018 09:58:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0b4dfde-1073-4ddb-a7c1-d831998bf90e</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Yes, this code should run nicely on the nRF52832.&lt;/p&gt;
&lt;p&gt;Looking at the code I think I wrote it for the nRF52832 in the first place, since I set the interrupt priority like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NVIC_SetPriority(MY_TIMER_IRQn, 7);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On the nRF51822 the lowest IRQ priority (highest number) is 3.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The code should work fine on both the nRF51 and the nRF52 series, since the IRQ priority is masked internally before it is set (so 7 will become 3 on the nRF51).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&amp;nbsp;&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/122929?ContentTypeID=1</link><pubDate>Tue, 06 Mar 2018 06:14:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26869401-1388-4532-bcf0-806c865ffe3f</guid><dc:creator>Rachit</dc:creator><description>&lt;p&gt;Can this code work for nrf52832 as well?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/83887?ContentTypeID=1</link><pubDate>Wed, 19 Apr 2017 12:11:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5766b6cc-dc55-4d2a-9a56-bdf2f737d1e1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Rakesh&lt;/p&gt;
&lt;p&gt;As mentioned by Endnode it is quite simple to have one of the TIMER modules return the time elapsed in milliseconds.&lt;/p&gt;
&lt;p&gt;I made a quick example for this based on the template example in the SDK:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define MY_TIMER            NRF_TIMER1
#define MY_TIMER_IRQn       TIMER1_IRQn
#define MY_TIMER_IRQHandler TIMER1_IRQHandler

static uint32_t my_timer_seconds;

static void my_timer_start(void)
{
    // Reset the second variable
    my_timer_seconds = 0;
    
    // Ensure the timer uses 24-bit bitmode or higher
    MY_TIMER-&amp;gt;BITMODE = TIMER_BITMODE_BITMODE_24Bit &amp;lt;&amp;lt; TIMER_BITMODE_BITMODE_Pos;
    
    // Set the prescaler to 4, for a timer interval of 1 us (16M / 2^4)
    MY_TIMER-&amp;gt;PRESCALER = 4;
    
    // Set the CC[0] register to hit after 1 second
    MY_TIMER-&amp;gt;CC[0] = 1000000;
    
    // Make sure the timer clears after reaching CC[0]
    MY_TIMER-&amp;gt;SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk;
    
    // Trigger the interrupt when reaching CC[0]
    MY_TIMER-&amp;gt;INTENSET = TIMER_INTENSET_COMPARE0_Msk;
    
    // Set a low IRQ priority and enable interrupts for the timer module
    NVIC_SetPriority(MY_TIMER_IRQn, 7);
    NVIC_EnableIRQ(MY_TIMER_IRQn);
    
    // Clear and start the timer
    MY_TIMER-&amp;gt;TASKS_CLEAR = 1;
    MY_TIMER-&amp;gt;TASKS_START = 1;
}

static uint32_t my_timer_get_ms(void)
{
    // Store the current value of the timer in the CC[1] register, by triggering the capture task
    MY_TIMER-&amp;gt;TASKS_CAPTURE[1] = 1;
    
    // Combine the state of the second variable with the current timer state, and return the result
    return (my_timer_seconds * 1000) + (MY_TIMER-&amp;gt;CC[1] / 1000);
}

static uint64_t my_timer_get_us(void)
{
    // Store the current value of the timer in the CC[1] register, by triggering the capture task
    MY_TIMER-&amp;gt;TASKS_CAPTURE[1] = 1;
    
    // Combine the state of the second variable with the current timer state, and return the result
    return (uint64_t)my_timer_seconds * 1000000 + MY_TIMER-&amp;gt;CC[1];
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    // Enable LED_1
    nrf_gpio_cfg_output(LED_1);
    
    // Enable and start the timer
    my_timer_start();
    
    while (true)
    {
        // Toggle LED_1 every second based on the time value returned by my_timer_get_ms()
        nrf_gpio_pin_write(LED_1, (my_timer_get_ms() / 1000) % 2);
    }
}
/** @} */

// Timer interrupt handler
void MY_TIMER_IRQHandler(void)
{
    if(MY_TIMER-&amp;gt;EVENTS_COMPARE[0])
    {
        MY_TIMER-&amp;gt;EVENTS_COMPARE[0] = 0;

        // Increment the second variable
        my_timer_seconds++;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Just copy/paste the above code into the template project if you want to try it out.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;
Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/83882?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 10:03:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fc140c0-570f-4620-a675-4f49662a226f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;try out &lt;a href="https://devzone.nordicsemi.com/question/53893/best-way-to-implement-system-clock-on-nrf51/"&gt;this&lt;/a&gt; thread and the answer from Clem Taylor. Maybe his implementation is useful for you here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/83886?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 06:50:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4200146e-4475-43dd-9074-ddcaa476701f</guid><dc:creator>Rakesh</dc:creator><description>&lt;p&gt;Hello Sir,&lt;/p&gt;
&lt;p&gt;In Arduino we had a direct function called millies(), Which starts timer in milliseconds.
Sameway do we have a any function in nordic which can we print timer function milliseconds, I am very beginner to Nordic, Please kindly help me sir.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/83885?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 06:28:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2ffae1e-1936-49c1-92b1-c779c28a6c92</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;What do you mean by printing time? If you want to track date and day-time you need to implement it on top of simple timer. Start with choosing right prescaler (depends on what resolution you want to track and what overflow period), then implement conversion functions from native RTC units to milliseconds/seconds/minutes/hours/days and finally you need to start the RTC after start of your board and &amp;quot;seed&amp;quot; the algorithm with some external time (if you want to have it in sync). This is quite general problem/method so you probably can find many open source examples on the internet...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/83884?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2017 06:19:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b9bb020-fba9-4e8b-baab-68e32d7d6383</guid><dc:creator>Rakesh</dc:creator><description>&lt;p&gt;Thankyou sir,&lt;/p&gt;
&lt;p&gt;I could see that library, could not understand how to print time, Please kindly help me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to call Time() function in Nordic nrf518222(Milliseconds) ??</title><link>https://devzone.nordicsemi.com/thread/83883?ContentTypeID=1</link><pubDate>Mon, 17 Apr 2017 09:18:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:577c67ea-c8f3-47bf-9c87-c3ab853c0b86</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hello Rakesh,&lt;/p&gt;
&lt;p&gt;there is &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.0.0/lib_timer.html?cp=4_0_0_3_39"&gt;&lt;code&gt;app_timer&lt;/code&gt; library&lt;/a&gt; and examples in nRF5 SDK, these can make any time-related async calls. It depends what your magic &lt;code&gt;Time()&lt;/code&gt; function should do, you will need to code it yourself.&lt;/p&gt;
&lt;p&gt;Cheers Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>