<?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>I want to log time stamp  in units of one second using app_timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/47605/i-want-to-log-time-stamp-in-units-of-one-second-using-app_timer</link><description>The problem is shown in the picture below. 
 
 It is normal for 10 seconds after activating the timer. 
 As you can see in the picture, the value of the time stamp changes abnormally. 
 
 This is the timer handler source code. 
 There is nothing special</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 May 2019 05:52:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/47605/i-want-to-log-time-stamp-in-units-of-one-second-using-app_timer" /><item><title>RE: I want to log time stamp  in units of one second using app_timer</title><link>https://devzone.nordicsemi.com/thread/188935?ContentTypeID=1</link><pubDate>Fri, 24 May 2019 05:52:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16dfb629-1155-40ff-9881-deb40d8f15e4</guid><dc:creator>npenny01</dc:creator><description>&lt;p&gt;Thanks to that, the problem is solved.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to log time stamp  in units of one second using app_timer</title><link>https://devzone.nordicsemi.com/thread/188786?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 10:08:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dacc7535-00fc-47e3-ab89-fa3f20267830</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There&amp;#39;s your problem ;)&lt;/p&gt;
&lt;p&gt;If you initialize the confirmed_send_packet[] buffer to &amp;quot;&amp;quot; it will only contain a single byte (the 0 termination character). Once you start writing to any index &amp;gt; 0 in the array you are writing outside the array itself, corrupting other variables.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You have to initialize the array to be large enough for future&amp;nbsp;writes to it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Looking at your code it would have to be at least 2*14 + 1 = 29 bytes in size, so if you change the initialization like this it should work:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;static char confirmed_send_packet[29]=&amp;quot;&amp;quot;;&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: I want to log time stamp  in units of one second using app_timer</title><link>https://devzone.nordicsemi.com/thread/188668?ContentTypeID=1</link><pubDate>Thu, 23 May 2019 01:05:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9f7678b-2b6d-4760-869d-9ad7cf83a14d</guid><dc:creator>npenny01</dc:creator><description>&lt;p&gt;&lt;span style="font-family:inherit;"&gt;Global Variable declaration&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:inherit;"&gt;static uint8_t confirmed_msg_buffer[14];&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;static char confirmed_send_packet[]=&amp;quot;&amp;quot;;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to log time stamp  in units of one second using app_timer</title><link>https://devzone.nordicsemi.com/thread/188582?ContentTypeID=1</link><pubDate>Wed, 22 May 2019 13:02:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e7081a25-4236-4092-9999-b1d42aebdae5</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If I understand you correctly the time_stamp_timer_handler(..) function appears to run at 1 second intervals as expected, but the value of the time_stamp variable is corrupted?&lt;/p&gt;
&lt;p&gt;Then the most obvious problem would be that the time_stamp variable is located after the confirmed_send_packet buffer in memory, and somehow the sprintf function is writing too far into the confirmed_send_packet buffer and overwriting the time_stamp variable instead.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;808466482 corresponds to 0x30303832, or &amp;quot;0082&amp;quot; in Ascii, which strengthens this theory.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is the size of the&amp;nbsp;&lt;span&gt;confirmed_send_packet array?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>