<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/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/"><channel><title>RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/38256/rtc-with-external-32-768khz-oscillator-on-lpc2378</link><description> 
I&amp;#39;m trying to use the RTC on my MCB2300 with Keil IDE. The NXP
example is only using the internal clock. My initialization seems to
be ok, according to the lpc23xx manual. But I&amp;#39;m facing 2 issues. 
First, my code is running only in debug mode. When</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/77211?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2009 23:26:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0f920c8e-70f0-4759-b1f8-53f56aaf8e51</guid><dc:creator>Aur&amp;#195;&amp;#169;lien MICHELVIOUX</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks a lot Shyam but as I have said before, it was an hardware
issue. My code is working. But thanks again, I really appreciate
it.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/55542?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2009 22:36:01 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0377ba76-6fdc-4185-b581-5fe971977918</guid><dc:creator>shyam ST</dc:creator><description>&lt;p&gt;&lt;p&gt;
Dear Aurelien&lt;br /&gt;
Shyam here, Do u rememember? that u send me code during my SPI
communication.&lt;/p&gt;

&lt;p&gt;
here I am sending Whole (RTC initalation ,RTC_ISR) RTC code which
is I implemented in my project.&lt;/p&gt;

&lt;pre&gt;
void InitRTC(void)
{
//  Enable power for RTC
        PCONP |= 0x200;
//  CTC reset and select RTC clock from 32 Khz.oscillator
        RTC_CCR = 0x12;
//  Clear RTC interrupt register
        RTC_ILR = 0xFF;
//  Dasable all the alrams.
        RTC_AMR = 0xFF;
//  Enable only second count interrupt.
        RTC_CIIR = 0x01;            // minute
//  Disable all subsecond interrupts.
        RTC_CISS = 0;
//  Enable RTC
        RTC_CCR = 0x11;
        return;
}
void Set_RTC(RTC Time)
{
        RTC_CCR &amp;amp;= 0xFE;
        RTC_SEC = Time.RTC_Sec;
//  Minute value [0-59]
        RTC_MIN = Time.RTC_Min;
//  Hour value [0-23]
        RTC_HOUR = Time.RTC_Hour;
//  Day of week value [0-6]
        RTC_DOW = Time.RTC_Wday;
//  Day of month value [1-31]
        RTC_DOM = Time.RTC_Mday;
//  Month value [1-12]
        RTC_MONTH = Time.RTC_Mon;
//  Year value
        RTC_YEAR = Time.RTC_Year;
//  Day of year value [1-365]
        RTC_DOY = Time.RTC_Yday;
        RTC_CCR |= 0x01;
        return;
}
RTC Read_RTC(void)
{
        RTC Local_time;
        Local_time.RTC_Sec = ((RTC_CTIME0 &amp;amp; 0x0000003F)&amp;gt;&amp;gt;0);
        rtcdata = ((RTC_CTIME0 &amp;amp; 0x0000003F)&amp;gt;&amp;gt;0);
//  Minute value [0-59]
        Local_time.RTC_Min = ((RTC_CTIME0 &amp;amp; 0x00003F00)&amp;gt;&amp;gt;8);
//  Hour value [0-23]
        Local_time.RTC_Hour = ((RTC_CTIME0 &amp;amp; 0x001F0000)&amp;gt;&amp;gt;16);
//  Day of week value [0-6]
        Local_time.RTC_Wday = ((RTC_CTIME0 &amp;amp; 0x07000000)&amp;gt;&amp;gt;24) ;
//  Day of month value [1-31]
        Local_time.RTC_Mday = ((RTC_CTIME1 &amp;amp; 0x0000001F)&amp;gt;&amp;gt;0);
//  Month value [1-12]
        Local_time.RTC_Mon = ((RTC_CTIME1 &amp;amp; 0x0000FF00)&amp;gt;&amp;gt;8);
//  Year value
        Local_time.RTC_Year = ((RTC_CTIME1 &amp;amp; 0x0FFF0000)&amp;gt;&amp;gt;16);
//  Day of year value [1-365]
        Local_time.RTC_Yday = RTC_DOY;
        RTC_CCR |= 0x01;
        return (Local_time);
}
void RTC_ISR (void) __irq
{

        if (RTC_ILR &amp;amp;=0x00000001)
        {

             Count++;
        }
        RTC_ILR = 0x00000001;
        VICVectAddr = 0x00000000;
}
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
if any problem give me meg.&lt;/p&gt;

&lt;p&gt;
Thanks&lt;br /&gt;
Shyam T.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/130445?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2009 01:39:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:12d982dd-4fe6-4afc-8c48-400ec1219a3c</guid><dc:creator>Aur&amp;#195;&amp;#169;lien MICHELVIOUX</dc:creator><description>&lt;p&gt;&lt;p&gt;
No, I&amp;#39;ve just checked again. I used ULINK ARM Debugger...&lt;br /&gt;
It seems that the RTC was using the main clock and not the external
oscillator. It&amp;#39;s so weird but I&amp;#39;ve lost enough time to investigate
it.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/125276?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2009 01:32:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f60d32fa-86c0-4c9b-90bd-75c4b9044a29</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot; ... behaviour in debug mode had confused me (crazy behaviour
that made a clock without external oscillator)!&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Are you sure it was just debug mode, and not the
&lt;b&gt;Simulator&lt;/b&gt;...?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/114721?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2009 01:22:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3cb21c04-8a24-4cb3-9036-a645b1efed27</guid><dc:creator>Aur&amp;#195;&amp;#169;lien MICHELVIOUX</dc:creator><description>&lt;p&gt;&lt;p&gt;
Well, I finally find my problem : it comes from the hardware. The
crystal on my MCB2300 seems to be broken. I should have check it
before but the behaviour in debug mode had confused me (crazy
behaviour that made a clock without external oscillator)! Moreover, I
used to trust keil&amp;#39;s hardware.&lt;br /&gt;
Anyway, it&amp;#39;s working now and I understand what was going on, so
that&amp;#39;s the point !&lt;br /&gt;
Thanks again John.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/101678?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2009 23:44:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:75d6e0c9-5aa6-419f-9772-6dddc0c738fa</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
What does your RTCHandler() do?&lt;/p&gt;

&lt;p&gt;
You said that your code doesn&amp;#39;t work in normal mode.&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&amp;quot;When not in debug mode, it seems that interrupt is never
fired.&amp;quot;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
If the &amp;quot;Counter Increment Interrupt&amp;quot; is fired, what will you
see?&lt;/p&gt;

&lt;p&gt;
Could you please confirm that, in debug mode, you really get a
&amp;quot;Counter Increment Interrupt&amp;quot; (RTCCIF)? not an &amp;quot;alarm registers
generated interrupt&amp;quot; (RTCALF), neither a &amp;quot;Counter Increment
Sub-Seconds interrupt&amp;quot; (RTSSF).&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/89586?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2009 23:11:32 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5ff18f68-85c2-4965-96f1-88295e4bee3b</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
Maybe, add the below code to your RTCInit()&lt;/p&gt;

&lt;pre&gt;
  RTC_CISS = 0;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
(Counter Increment Select Mask Register)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/77210?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2009 23:10:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0b0c7b17-a5b9-48d7-a0bf-0e4746c38ebf</guid><dc:creator>Aur&amp;#195;&amp;#169;lien MICHELVIOUX</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks for answering. I tryed a lot of different initialization
but I took care about the RTC_CIIR register. Actually, here is my
RTCinit() :&lt;/p&gt;

&lt;pre&gt;
void RTCInit( void )
{
    alarm_on = 0;
    PCONP |= (1&amp;lt;&amp;lt;9); /* must be powered during configuration*/
    /*--- Initialize registers ---*/
    RTC_ILR = ILR_RTCALF | ILR_RTCCIF; /* Disable 32&amp;#39;768 interrupt */
    RTC_AMR = 0;  /* alarm mask register */
    RTC_CIIR = 0; /* counter increment interrupt */
    RTC_CCR |= CCR_CLKSRC;  /* CCR_CLKSRC = 0x10 : external oscillator */

/*    //RTC_PREINT = PREINT_RTC;    // 0
    //RTC_PREFRAC = PREFRAC_RTC;  // 0  */

    RTC_CIIR |= 1; /* sec interrupt */
    return;
}
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
Any idea ?&lt;br /&gt;
Thanks again.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: RTC with external 32.768kHz oscillator on lpc2378</title><link>https://community.arm.com/thread/55534?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2009 19:34:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:4f644f32-8eef-4f42-8f18-7afe8814cd34</guid><dc:creator>John Linq</dc:creator><description>&lt;p&gt;&lt;p&gt;
(I don&amp;#39;t know much about this.)&lt;/p&gt;

&lt;p&gt;
Does your RTCInit() look like the below?&lt;/p&gt;

&lt;pre&gt;
void RTCInit( void )
{
  alarm_on = 0;

  /*--- Initialize registers ---*/
  RTC_AMR = 0;
  &lt;b&gt;RTC_CIIR = 0;&lt;/b&gt;
  RTC_CCR = 0;
  RTC_PREINT = PREINT_RTC;
  RTC_PREFRAC = PREFRAC_RTC;
  return;
}
&lt;/pre&gt;

&lt;p&gt;
If it does, please check the &amp;quot;RTC_CIIR = 0;&amp;quot;&lt;br /&gt;
(Counter Increment Interrupt Register)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>