<?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>nrf52840 Calendar Timestamp issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48915/nrf52840-calendar-timestamp-issue</link><description>We have successfully implemented &amp;amp; tested the working of SYSTEM ON SLEEP MODE feature in our nrf52840 devices. 
 Please reply to below queries for a similar issue: 
 
 Will TIMESTAMP from internal RTC work in SYSTEM ON SLEEP MODE. We are implementing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 25 Jun 2019 11:30:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48915/nrf52840-calendar-timestamp-issue" /><item><title>RE: nrf52840 Calendar Timestamp issue</title><link>https://devzone.nordicsemi.com/thread/194621?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 11:30:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c137f3b8-4bad-43ef-a83b-5e6b2e4b1d1a</guid><dc:creator>Edvin</dc:creator><description>[quote user="Vishal Aditya"]Yes tested standalone in &lt;strong&gt;peripheral&lt;/strong&gt; as well not working[/quote]
&lt;p&gt;&amp;nbsp;Maybe you should try that before mixing the softdevice into the project, so that you understand how it works.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Vishal Aditya"]I am debugging properly with break-points at each line.[/quote]
&lt;p&gt;&amp;nbsp;You can&amp;nbsp;&lt;strong&gt;NOT&lt;/strong&gt; do this with the softdevice. sorry. I can&amp;#39;t stress this enough.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Try with the project from the github repository that you linked to first. See that you get the calendar up and running first.&lt;/p&gt;
&lt;p&gt;Make sure that you end all your UART inputs with CR (Carriage return).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Do you mean that the MCU is getting stuck on the line:&amp;nbsp;nrf_cal_set_callback(calendar_updated, 4);?&lt;/p&gt;
&lt;p&gt;That is not possible. Try to enter this function, and set breakpoints inside it. Where is it stuck?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 Calendar Timestamp issue</title><link>https://devzone.nordicsemi.com/thread/194604?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 10:38:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:472a3a13-92fe-4378-9e6f-e486b00a729f</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Thanks for your detailed answers!&lt;/p&gt;
&lt;p&gt;I am debugging properly with break-points at each line.&lt;/p&gt;
&lt;p&gt;I am trying to set timestamp using function below from &lt;a title="https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.c" href="https://github.com/NordicPlayground/nrf5-calendar-example/blob/master/nrf_calendar.c"&gt;&lt;strong&gt;nrf_calendar&lt;/strong&gt; &lt;/a&gt;example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void nrf_cal_set_time(uint32_t year, uint32_t month, uint32_t day, uint32_t hour, uint32_t minute, uint32_t second)
{
    static time_t uncal_difftime, difftime, newtime;
    time_struct.tm_year = year - 1900;
    time_struct.tm_mon = month;
    time_struct.tm_mday = day;
    time_struct.tm_hour = hour;
    time_struct.tm_min = minute;
    time_struct.tm_sec = second;   
    newtime = mktime(&amp;amp;time_struct);
    CAL_RTC-&amp;gt;TASKS_CLEAR = 1;  
    
    // Calculate the calibration offset 
    if(m_last_calibrate_time != 0)
    {
        difftime = newtime - m_last_calibrate_time;
        uncal_difftime = m_time - m_last_calibrate_time;
        m_calibrate_factor = (float)difftime / (float)uncal_difftime;
    }
    
    // Assign the new time to the local time variables
    m_time = m_last_calibrate_time = newtime;
}    &lt;/pre&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Function Call below:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t g_year, g_month, g_day, g_hour, g_minute, g_second;

g_year = 2018;
g_month = 10;
g_day = 15;
g_hour = 5;
g_minute = 1;
g_second = 29;
nrf_cal_set_time(g_year, g_month, g_day, g_hour, g_minute, g_second);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please let me know how I can further debug into issue for setting time as I am able to get time with this function:&amp;nbsp;&lt;strong&gt;nrf_cal_get_time_calibrated()&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Result:&amp;nbsp;01/01/70 - 00:00:00&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Also, in int main(void){}&lt;/strong&gt;&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);
nrf_cal_init();
nrf_cal_set_callback(calendar_updated, 4);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;MCU stucks here.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;We have multiple peripherals &amp;amp; final ble_peripheral code which is all working for our devices, we are adding extra features to the same.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes merged with &lt;strong&gt;ble_peripheral&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Yes tested standalone in &lt;strong&gt;peripheral&lt;/strong&gt; as well not working&lt;/p&gt;
[quote userid="26071" url="~/f/nordic-q-a/48915/nrf52840-calendar-timestamp-issue/194522"]There are many things that can go wrong that I can think of when I try to imagine what you may or may not be doing, but it is difficult without knowing much.&amp;nbsp;[/quote]
&lt;p&gt;Let me know all possible queries to resolve this issue I will answer all...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am not setting time from app_uart itself, 1st priority trying to set timestamp manually &amp;amp; maintain it for all reading cycles in SYSTEM ON SLEEP MODE. Further, we will develop our custom Android App &amp;amp; get &lt;strong&gt;AUTOSYNC&lt;/strong&gt; of TIMESTAMP.&lt;/p&gt;
&lt;p&gt;As, such I&amp;nbsp;am not falling or&amp;nbsp;encountering any softdevice issue while debugging with Keil5, so I am not getting troubles with softdevice thing you mentioned above.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Vishal Aditya&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Embedded Software Engineer&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 Calendar Timestamp issue</title><link>https://devzone.nordicsemi.com/thread/194522?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 07:34:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf008429-85af-4e94-8bfa-cf6529ea8cf4</guid><dc:creator>Edvin</dc:creator><description>[quote user="Vishal Aditya"]nrf_cal_set_time() function is not working getting stuck/hanged incountered after debugging on nrf52840 DK in Keil 5 with a break point.[/quote]
&lt;p&gt;&amp;nbsp;So it stops because you have set a breakpoint? Isn&amp;#39;t that the intention of breakpoints?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Or do you mean that you aren&amp;#39;t able to input the time correctly? Maybe you are stuck on the &amp;quot;Enter year:&amp;quot; command?&lt;/p&gt;
&lt;p&gt;Note that the UART is looking for a CR = 0x0D (Carriage Return), and not the Linefeed. For your reference: &lt;a href="https://en.wikipedia.org/wiki/File:ASCII-Table.svg" rel="noopener noreferrer" target="_blank"&gt;Ascii table&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="Vishal Aditya"]Please confirm if&amp;nbsp;&lt;strong&gt;TIMESTAMP&lt;/strong&gt;&lt;span&gt;&amp;nbsp;from internal RTC&amp;nbsp;will work in &lt;strong&gt;SYSTEM ON SLEEP MODE?&lt;/strong&gt;&lt;/span&gt;[/quote]
&lt;p&gt;&amp;nbsp;The RTC doesn&amp;#39;t have a TIMESTAMP directly. But if your question is whether the RTC will run in&amp;nbsp;SYSTEM ON&amp;nbsp;mode, then the answer is yes. However, this example doesn&amp;#39;t use system on mode. Have you merged this example into a BLE example? Did you test it standalone first?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;There are many things that can go wrong that I can think of when I try to imagine what you may or may not be doing, but it is difficult without knowing much.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you do any changes to the project? It works unmodified in the SDK15.2.0. Did you try to copy it into a BLE project? It may be that the softdevice is not a huge fan of app_uart_get (but I think it will be alright). The softdevice is not working after a break on a breakpoint. At that point, you need to reset your device, because the softdevice has missed too many time critical events (if you use the softdevice).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 Calendar Timestamp issue</title><link>https://devzone.nordicsemi.com/thread/194499?ContentTypeID=1</link><pubDate>Tue, 25 Jun 2019 06:44:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02ae0fb2-2125-4766-88b9-bcea3e02116f</guid><dc:creator>Vishal Aditya</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;We are using &lt;strong&gt;SDK 15.2:&amp;nbsp;nRF5_SDK_15.2.0_9412b96\examples\ble_peripheral&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Issue with&amp;nbsp;&lt;a href="https://github.com/NordicPlayground/nrf5-calendar-example"&gt;https://github.com/NordicPlayground/nrf5-calendar-example&lt;/a&gt; is below:&lt;/p&gt;
&lt;p&gt;nrf_cal_set_time() function is not working getting stuck/hanged incountered after debugging on nrf52840 DK in Keil 5 with a break point.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Please confirm if&amp;nbsp;&lt;strong&gt;TIMESTAMP&lt;/strong&gt;&lt;span&gt;&amp;nbsp;from internal RTC&amp;nbsp;will work in &lt;strong&gt;SYSTEM ON SLEEP MODE?&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 Calendar Timestamp issue</title><link>https://devzone.nordicsemi.com/thread/194319?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 11:32:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe863ede-5fc6-4278-89a6-9188e57281f9</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello Vishal,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]ABOVE IS NOT WORKING NOT ABLE TO SET TIMESTAMP TO CURRENT DATE/TIME OR MAINTAIN TIMESTAMP[/quote]
&lt;p&gt;&amp;nbsp;Can you clarify the behavior? What do you mean by &amp;quot;&lt;strong&gt;NOT WORKING&lt;/strong&gt;&amp;quot;? Does the error handler trigger? Are you not able to connect? What is happening?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]&amp;nbsp;&lt;span&gt;&lt;/span&gt;&lt;strong&gt; How to properly implement &amp;amp; maintain TIMESTAMP for device with SYSTEM ON SLEEP MODE? Any code snippet or calendar drivers that will work with internal RTC only as we don&amp;#39;t have external RTC provision due to device size constrains?&lt;/strong&gt;[/quote]
&lt;p&gt;&amp;nbsp;Well... there is that project that you link to. It is not something that is officially provided by Nordic, but it was made for a project at one point, and we published it in case someone else could benefit from it. There is no library in the SDK made for this.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I suspect that you use a different SDK version than the one used in the NordicPlayground repository, is that correct? If so, you probably need to adapt some of the functions to the correct SDK version.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Why don&amp;#39;t you describe how it behaves, and what SDK version you are trying to use, and we can look into it together.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>