<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RTC - Which Counter Increment Interrupt Fired? in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-Which-Counter-Increment-Interrupt-Fired/m-p/521819#M4455</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by brownm on Mon May 13 22:12:59 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;P&gt;Hi There&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I would like to set multiple (two) CIIR flags in the realtime clock of an LPC1768 as follows&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;/* Set the CIIR for second counter interrupt*/&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;/* Set the CIIR for day of week rollover interrupt*/&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_DAYOFWEEK, ENABLE);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;This is fine, but the manual says that If CIIR is enabled for a particular counter, then every time the counter is incremented an interrupt is generated.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;RTCCIF When one, the Counter Increment Interrupt block generated an interrupt. Writing a one to this bit location clears the counter increment interrupt.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;27.6.2.3 Counter Increment Interrupt Register (CIIR - 0x4002 400C) The Counter Increment Interrupt Register (CIIR) gives the ability to generate an interrupt every time a counter is incremented. This interrupt remains valid until cleared by writing a 1 to bit 0 of the Interrupt Location Register&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Question, which bit set the interrupt? it doesn't actually tell you which CIIR bit fired the increment interrupt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I would like to do something along the lines of the following.&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;void RTC_IRQHandler(void){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;/* This is increment counter interrupt*/&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;if (RTC_GetIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE))&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;{&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;if(LPC_RTC-&amp;amp;gt;CIIR &amp;amp;amp; RTC_CIIR_IMSEC){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;uptime++;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;ntp_time++;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;if(LPC_RTC-&amp;amp;gt;CIIR &amp;amp;amp; RTC_CIIR_IMDOW){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;// Clear pending interrupt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;RTC_ClearIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Any thoughts appreciated&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Marshall&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 16:39:03 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T16:39:03Z</dc:date>
    <item>
      <title>RTC - Which Counter Increment Interrupt Fired?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-Which-Counter-Increment-Interrupt-Fired/m-p/521819#M4455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by brownm on Mon May 13 22:12:59 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;P&gt;Hi There&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I would like to set multiple (two) CIIR flags in the realtime clock of an LPC1768 as follows&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;/* Set the CIIR for second counter interrupt*/&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;/* Set the CIIR for day of week rollover interrupt*/&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_DAYOFWEEK, ENABLE);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;This is fine, but the manual says that If CIIR is enabled for a particular counter, then every time the counter is incremented an interrupt is generated.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;RTCCIF When one, the Counter Increment Interrupt block generated an interrupt. Writing a one to this bit location clears the counter increment interrupt.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;27.6.2.3 Counter Increment Interrupt Register (CIIR - 0x4002 400C) The Counter Increment Interrupt Register (CIIR) gives the ability to generate an interrupt every time a counter is incremented. This interrupt remains valid until cleared by writing a 1 to bit 0 of the Interrupt Location Register&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Question, which bit set the interrupt? it doesn't actually tell you which CIIR bit fired the increment interrupt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I would like to do something along the lines of the following.&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;void RTC_IRQHandler(void){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;/* This is increment counter interrupt*/&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;if (RTC_GetIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE))&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;{&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;if(LPC_RTC-&amp;amp;gt;CIIR &amp;amp;amp; RTC_CIIR_IMSEC){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;uptime++;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;ntp_time++;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;if(LPC_RTC-&amp;amp;gt;CIIR &amp;amp;amp; RTC_CIIR_IMDOW){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;// Clear pending interrupt&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;RTC_ClearIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;lt;span class="Apple-tab-span" style="white-space: pre;"&amp;gt; &amp;lt;/span&amp;gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Any thoughts appreciated&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Marshall&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:39:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-Which-Counter-Increment-Interrupt-Fired/m-p/521819#M4455</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: RTC - Which Counter Increment Interrupt Fired?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-Which-Counter-Increment-Interrupt-Fired/m-p/521820#M4456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Wed Jul 17 11:34:39 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Basically, you just can't tell which counter changed from the RTC register interface.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The interrupt is an OR of (sec upd AND sec enable) OR (dow upd AND dow enable)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and similarly for any others that you enable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, the secs will roll over at the same time as the day of week anyway.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My solution to this lack of feature is to create my own status bitmap by:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the change interrupt (seconds only enabled):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) read date/time registers either individually or combined.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) for each item, compare with program variable(s) previous value(s)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; and set the appropriate bit if different.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) copy current values to previous values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4) write to RTCCIF of ILR register to clear the interrupt.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can then test the bits in the created status change mask to&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;do secondly, hourly, daily, etc. operations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know it sucks, but you won't change anything by moaning.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[The forum changed bracket ess bracket to a smiley -- pooh!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:39:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/RTC-Which-Counter-Increment-Interrupt-Fired/m-p/521820#M4456</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:39:04Z</dc:date>
    </item>
  </channel>
</rss>

