RTC - Which Counter Increment Interrupt Fired?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RTC - Which Counter Increment Interrupt Fired?

724 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by brownm on Mon May 13 22:12:59 MST 2013

Hi There 


 


I would like to set multiple (two) CIIR flags in the realtime clock of an LPC1768 as follows


<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Set the CIIR for second counter interrupt*/


<span class="Apple-tab-span" style="white-space: pre;"> </span>RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_SECOND, ENABLE);


<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Set the CIIR for day of week rollover interrupt*/


<span class="Apple-tab-span" style="white-space: pre;"> </span>RTC_CntIncrIntConfig (LPC_RTC, RTC_TIMETYPE_DAYOFWEEK, ENABLE);


 


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.


RTCCIF When one, the Counter Increment Interrupt block generated an interrupt. Writing a one to this bit location clears the counter increment interrupt.


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


 


Question, which bit set the interrupt? it doesn't actually tell you which CIIR bit fired the increment interrupt


 


I would like to do something along the lines of the following. 


void RTC_IRQHandler(void){


<span class="Apple-tab-span" style="white-space: pre;"> </span>/* This is increment counter interrupt*/


<span class="Apple-tab-span" style="white-space: pre;"> </span>if (RTC_GetIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE))<span class="Apple-tab-span" style="white-space: pre;"> </span>{


<span class="Apple-tab-span" style="white-space: pre;"> </span>if(LPC_RTC-&gt;CIIR &amp; RTC_CIIR_IMSEC){


<span class="Apple-tab-span" style="white-space: pre;"> </span>uptime++;


<span class="Apple-tab-span" style="white-space: pre;"> </span>ntp_time++;


<span class="Apple-tab-span" style="white-space: pre;"> </span>}


<span class="Apple-tab-span" style="white-space: pre;"> </span>if(LPC_RTC-&gt;CIIR &amp; RTC_CIIR_IMDOW){


<span class="Apple-tab-span" style="white-space: pre;"> </span>;


<span class="Apple-tab-span" style="white-space: pre;"> </span>}


<span class="Apple-tab-span" style="white-space: pre;"> </span>// Clear pending interrupt


<span class="Apple-tab-span" style="white-space: pre;"> </span>RTC_ClearIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE);


<span class="Apple-tab-span" style="white-space: pre;"> </span>}


Any thoughts appreciated 


Regards


 


Marshall

Labels (1)
0 Kudos
1 Reply

675 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Wed Jul 17 11:34:39 MST 2013
Basically, you just can't tell which counter changed from the RTC register interface.

The interrupt is an OR of (sec upd AND sec enable) OR (dow upd AND dow enable)
and similarly for any others that you enable.

Also, the secs will roll over at the same time as the day of week anyway.

My solution to this lack of feature is to create my own status bitmap by:

On the change interrupt (seconds only enabled):

1) read date/time registers either individually or combined.
2) for each item, compare with program variable(s) previous value(s)
   and set the appropriate bit if different.
3) copy current values to previous values.
4) write to RTCCIF of ILR register to clear the interrupt.

You can then test the bits in the created status change mask to
do secondly, hourly, daily, etc. operations.

I know it sucks, but you won't change anything by moaning.

Cheers, Mike
[The forum changed bracket ess bracket to a smiley -- pooh!






0 Kudos