<div dir="ltr">Hi, thanks for answering, but spnsext01 test works ok. <div>After a while I noticed the problem:</div><div>The ticker interrupt has lower priority than any irq. When I entered the ticker:</div><div> The bit PENDSTSET of the ICSR register that was used to check whether the sysclk had a pending interrupt or not went to 0,</div><div>But since the ticker has lower priority, my GPIO interrupt preempted the ticker interrupt before updating the binuptime, and asked for the time, when checking for that bit inside rtems_timecounter_simple_downcounter_get, it was 0, but the tick time wasn't added correctly to binuptime and the timer had already reset. So there is the difference I noticed from time to time.</div><div><br></div><div>The solution I propose include two things: One is to put the interrupt fence in Clock_isr function before calling Clock_driver_support_at_tick, or make another Clock_isr function, that "atomically" clears the pending flag (systick->csr) and updates the binuptime.</div><div><br></div><div>The other is to change _ARMV7M_TC_is_pending to not check for the mentioned bit. instead we should check  for the     systick->csr register, but since that register clears after each read we should "help" that flag with another bool:</div><div><br></div><div>static bool is_count_pending = false;<br></div><div><div>static bool _ARMV7M_TC_is_pending(rtems_timecounter_simple *tc)</div><div>{</div><div><br></div><div>  volatile ARMV7M_Systick *systick = _ARMV7M_Systick;</div><div><br></div><div>  if (!is_count_pending)</div><div>  {</div><div>    is_count_pending = (systick->csr & ARMV7M_SYSTICK_CSR_COUNTFLAG) != 0;</div><div>  }</div><div><br></div><div>  return is_count_pending;</div><div>}</div></div><div><br></div><div>And in the function in charge of clearing that bit we should do this:</div><div><br></div><div><div>static void _ARMV7M_Systick_at_tick(void)</div><div>{</div><div>  volatile ARMV7M_Systick *systick = _ARMV7M_Systick;</div><div><br></div><div>  /* Clear COUNTFLAG */</div><div>  systick->csr;</div><div><br></div><div>  is_count_pending = false;</div><div>}</div></div><div><br></div><div><br></div><div>With this solution I can have any order in priorities between the interrupts, and it works.</div><div>If you approve this I will submit the patch.</div><div>I suggest checking for similar problems in other bsps.</div><div>Besides this I have another question: What is the best to set for the ticker priority? It should have a higher/same/lower priority than the other interrupts?</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 21, 2015 at 4:39 AM, Sebastian Huber <span dir="ltr"><<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
works the spnsext01 test on your target?<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Sebastian Huber, embedded brains GmbH<br>
<br>
Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>
Phone   : +49 89 189 47 41-16<br>
Fax     : +49 89 189 47 41-09<br>
E-Mail  : <a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a><br>
PGP     : Public key available on request.<br>
<br>
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><span><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="font-size:16px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">______________________________</span></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><a href="http://www.tallertechnologies.com" target="_blank"><img src="http://www.tallertechnologies.com/templates/tallertechnologies/images/signature.png" width="200" height="78"></a></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><b style="font-weight:normal"><br><span style="font-size:16px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"></span></b></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><font face="verdana, sans-serif" size="4">Marcos Díaz</font></span></p><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt"><font color="#000000" face="verdana, sans-serif" size="2"><span style="line-height:17px;white-space:pre-wrap">Software Engineer</span></font></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><b style="font-weight:normal"><br><span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"></span></b></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><font face="arial, helvetica, sans-serif" size="1">San Lorenzo 47, 3rd Floor, Office 5</font></span></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><font face="arial, helvetica, sans-serif" size="1">Córdoba, Argentina </font></span></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><b style="font-weight:normal"><font face="arial, helvetica, sans-serif" size="1"><br><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"></span></font></b></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><font face="arial, helvetica, sans-serif" size="1"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Phone:</span><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> +54 351 4217888 / +54 351 4218211/ </span><span style="color:rgb(0,0,0);line-height:12px;white-space:pre-wrap">+54 351 7617452</span></font></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"></p><p dir="ltr" style="line-height:1.15;margin-top:0pt;margin-bottom:0pt"><font face="arial, helvetica, sans-serif" size="1"><span style="color:rgb(0,0,0);background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap">Skype:</span><span style="color:rgb(0,0,0);background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"> markdiaz22</span></font></p><div><span style="font-size:11px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre-wrap"><br></span></div></span></div></div>
</div>