<?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 make sure, that a compare event will be generated</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8150/how-to-make-sure-that-a-compare-event-will-be-generated</link><description>Hello,
I want to generate timer events as exact as possible, based on a time base that is defined by a runing timer. For example, I&amp;#39;ve setup timer0 to count up every 1&amp;#181;s and the time point, where I&amp;#39;ve started the timer is my anchor/T0 in time. When I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 15 Jul 2015 11:11:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8150/how-to-make-sure-that-a-compare-event-will-be-generated" /><item><title>RE: How to make sure, that a compare event will be generated</title><link>https://devzone.nordicsemi.com/thread/29304?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2015 11:11:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce6015aa-2c59-4910-972c-7bd978bf2402</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;This should work. Be careful about what priorities you give to the different things you need to do though, since you will still generate an interrupt if the cc has higher priority than the function you want to use to unconditionally reset it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure, that a compare event will be generated</title><link>https://devzone.nordicsemi.com/thread/29303?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2015 08:16:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5da9cd36-9582-4c38-b94c-3fcb804980a4</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Hi Øyvind,&lt;/p&gt;
&lt;p&gt;thank you very much for your input. So your basic idea is, to just look, if the current state of the timer and the destination compare state have a distance that is large enough to be sure, that when setting the cc register, the cc register will still be in front of the timer? As my timer is not going to wrap, that would be fairly easy.&lt;/p&gt;
&lt;p&gt;But I would have to disable interrupts before making the check (or do it in an interrupt handler; like in your PWM example), right? For me it’s not so important to hit the requested time very precisely, but to make sure that my event machine does not stop because an interrupt gets not generated.&lt;/p&gt;
&lt;p&gt;Do you think my approach, to unconditional set the cc register and check afterwards whether the counter overrun the cc register could work? I think I have to make sure, the state machine can cope with double generated interrupts.&lt;/p&gt;
&lt;p&gt;Thanks,
Torsten&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to make sure, that a compare event will be generated</title><link>https://devzone.nordicsemi.com/thread/29302?ContentTypeID=1</link><pubDate>Wed, 15 Jul 2015 07:06:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f2b5167-0f7a-41b5-aa62-8ab585c476c9</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have a look at how this is handled in the &lt;a href="https://github.com/NordicSemiconductor/nrf51-pwm-library/blob/master/nrf_pwm.c"&gt;pwm-library&lt;/a&gt; on github.  The idea is that you will only update the compare value if you&amp;#39;re within a safe margin.&lt;/p&gt;
&lt;p&gt;Things become harder if it is critical that you never hit the 600 mark if you&amp;#39;re trying to reset. Here you might save yourself some headache changing around your states instead.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>