Reply by Tim Mitchell October 7, 20092009-10-07
----Original Message----
From: l...
[mailto:l...] On Behalf Of Wagner Loebel
(GMAIL) Sent: 06 October 2009 17:26 To:
l... Subject: Re: [lpc2000] Re: RTC
doubt with LPC2368

> Really, the only way to get RTC working on reset or
> without power supply is selecting external crystal.
>
> But with this option there's no accuracy. I adjust the
> RTC few days ago and since then I'm wathing RTC
> forwarding 1 sec a day. After a long period the RTC time
> will be wrong !
>
> The LPC17xx have an auto calibration feature, very nice !
> http://www.nxp.com/acrobat_download/applicationnotes/AN10849_1.pdf
>
> But LPC2368 I'll need to create my own auto-calibrate
> function, by stopping the counter a right and little
> calculated ticks to maintain the correct time.
>
> Is this the right way ? Has anyone a better suggestion ?
>

We've done a couple of applications with LPC2478 RTC and it has been
much more accurate than that. Are the loading caps on the 32Khz crystal
correct, this can change the frequency.

--
Tim Mitchell

An Engineer's Guide to the LPC2100 Series

Reply by Michael Freeman October 6, 20092009-10-06
If you need better accuracy you need to use a external TCXO, and you may
need voltage divider on its output. I cannot remember if the 32K osc pins
are at core voltage or not, you will have to look this up. There is a wide
range of TCXOs for you to choose from, some will give you 30 seconds a year
loss.

Michael Freeman
Update Systems Inc.
-----Original Message-----
From: l... [mailto:l...]On Behalf Of
Wagner Loebel (GMAIL)
Sent: Tuesday, October 06, 2009 11:26 AM
To: l...
Subject: Re: [lpc2000] Re: RTC doubt with LPC2368
Really, the only way to get RTC working on reset or without power supply
is selecting external crystal.

But with this option there's no accuracy. I adjust the RTC few days ago
and since then I'm wathing RTC forwarding 1 sec a day. After a long period
the RTC time will be wrong !

The LPC17xx have an auto calibration feature, very nice !
http://www.nxp.com/acrobat_download/applicationnotes/AN10849_1.pdf

But LPC2368 I'll need to create my own auto-calibrate function, by
stopping the counter a right and little calculated ticks to maintain the
correct time.

Is this the right way ? Has anyone a better suggestion ?

Thanks

Wagner Loebel

----- Original Message -----
From: Tim Mitchell
To: l...
Sent: Monday, October 05, 2009 5:22 AM
Subject: RE: [lpc2000] Re: RTC doubt with LPC2368

I don't think you have selected the 32Khz crystal for the RTC
According to datasheet p566, to set 32Khz crystal you need to set CCR to
0x10 (bit 4)

> > >
> > > void RTCInit( void )
> > > {
> > > PCONP = PCONP | 0x200; //set bit PCRTC
> > >
> > > RTC_AMR = 0;
> > > RTC_CIIR = 0;
> > > //RTC_CISS = 0;
> > > RTC_CCR = 0x01; //0x11 ext.clock ;; 0x01 int.clock
> > > RTC_PREINT = PREINT_RTC; //0x0000016D
> > > RTC_PREFRAC = PREFRAC_RTC; //0x00001B00
> > >
> > > // Start RTC counters
> > > RTC_CCR |= CCR_CLKEN;
> > > RTC_ILR = ILR_RTCCIF;
> > > }
> > >

--
Tim Mitchell





Reply by "Wagner Loebel (GMAIL)" October 6, 20092009-10-06
Really, the only way to get RTC working on reset or without power supply is selecting external crystal.

But with this option there's no accuracy. I adjust the RTC few days ago and since then I'm wathing RTC forwarding 1 sec a day. After a long period the RTC time will be wrong !

The LPC17xx have an auto calibration feature, very nice !
http://www.nxp.com/acrobat_download/applicationnotes/AN10849_1.pdf

But LPC2368 I'll need to create my own auto-calibrate function, by stopping the counter a right and little calculated ticks to maintain the correct time.

Is this the right way ? Has anyone a better suggestion ?
Thanks

Wagner Loebel

----- Original Message -----
From: Tim Mitchell
To: l...
Sent: Monday, October 05, 2009 5:22 AM
Subject: RE: [lpc2000] Re: RTC doubt with LPC2368
I don't think you have selected the 32Khz crystal for the RTC
According to datasheet p566, to set 32Khz crystal you need to set CCR to
0x10 (bit 4)

> > >
> > > void RTCInit( void )
> > > {
> > > PCONP = PCONP | 0x200; //set bit PCRTC
> > >
> > > RTC_AMR = 0;
> > > RTC_CIIR = 0;
> > > //RTC_CISS = 0;
> > > RTC_CCR = 0x01; //0x11 ext.clock ;; 0x01 int.clock
> > > RTC_PREINT = PREINT_RTC; //0x0000016D
> > > RTC_PREFRAC = PREFRAC_RTC; //0x00001B00
> > >
> > > // Start RTC counters
> > > RTC_CCR |= CCR_CLKEN;
> > > RTC_ILR = ILR_RTCCIF;
> > > }
> > >

--
Tim Mitchell



Reply by Tim Mitchell October 5, 20092009-10-05
I don't think you have selected the 32Khz crystal for the RTC
According to datasheet p566, to set 32Khz crystal you need to set CCR to
0x10 (bit 4)

> > >
> > > void RTCInit( void )
> > > {
> > > PCONP = PCONP | 0x200; //set bit PCRTC
> > >
> > > RTC_AMR = 0;
> > > RTC_CIIR = 0;
> > > //RTC_CISS = 0;
> > > RTC_CCR = 0x01; //0x11 ext.clock ;; 0x01 int.clock
> > > RTC_PREINT = PREINT_RTC; //0x0000016D
> > > RTC_PREFRAC = PREFRAC_RTC; //0x00001B00
> > >
> > > // Start RTC counters
> > > RTC_CCR |= CCR_CLKEN;
> > > RTC_ILR = ILR_RTCCIF;
> > > }
> > >
--
Tim Mitchell

Reply by Felipe de A N L October 3, 20092009-10-03
Yes. there is two xtal, one for the RTC and one for the ARM7.

2009/10/3 gsntone

> Hi Wagner,
>
> "Man, your are doing things WRONG. To solve it, use external clock with a
> 32.768KHz xtal."
>
> With battery and external crystal for RTC your problem should be solved.
> (AFAIK my etteam-board has this 32.768 kHz crystal).
> This option is the only way to keep your RTC running.
>
> Hope this helps,
> Gerd
> --- In l... , "Wagner Loebel
> \(GMAIL\)" wrote:
> >
> > Hi everybody.
> >
> > I'm Wagner, I'm from Brazil. This is my first post here, I'm starting
> with ARM7 (I bought a board from ETT -Thailand with LPC2368) and I amazed
> with this uC, I always worked with COP8 from National (coding in assembly,
> crazy thing !!!) and recently with Z8Encore, but this ARM7 is impressive !
> >
> > Ok, I run a lot of samples in this board, web server, telnet, USB HID and
> MSD with SD-Card, etc etc. But now Its time to do some serious work...
> >
> > So I ported my codes from Z8Encore, put a LCD 16x2 to work, buzzer, leds
> blinking, bla bla bla. and... RTC. I run it from external clock and
> internal, both OK but I'm watching a strange behavior when running with
> internal clock. The RTC "stop to walk" during the time I maintain the reset
> switch pressed.
> >
> > Example:
> >
> > 1) RTC is running perfectly and shows 01:43:31 on LCD.
> > 2) Then I press reset switch and continue with reset pressed for about 10
> seconds;
> > 3) When I release the reset switch, the RTC shows the same time
> (01:43:31) and THEN start to "walk" normally.
> >
> > The same happens when I power off the board, even with a battery on Vbat.
> No matter how many seconds, or minutes or hours it was powered off, the RTC
> dont lose the values because it have a small 3V battery on it Vbat pins but
> the RTC only return to count seconds, minutes and hours when the power is ON
> and not RESET. I read in the manual the entire chapter about RTC and others
> parts but not found any clue on how to solve it.
> >
> > I guess its happenning 'cause when the device is powered off the main
> oscilator is not running and there's any pulse of clock to make de RTC
> "walk", even with a backup battery in VBAT, is it right ?
> >
> > Below this is my initialization code. Can anyone give me some idea or
> tell me if there is something wrong or missing with my initialization code.
> Or to tell me: "Man, your are doing things WRONG. To solve it, use external
> clock with a 32.768KHz xtal"
> >
> > Thanks in advance,
> >
> > Wagner Loebel
> >
> >
> > void RTCInit( void )
> > {
> > PCONP = PCONP | 0x200; //set bit PCRTC
> >
> > RTC_AMR = 0;
> > RTC_CIIR = 0;
> > //RTC_CISS = 0;
> > RTC_CCR = 0x01; //0x11 ext.clock ;; 0x01 int.clock
> > RTC_PREINT = PREINT_RTC; //0x0000016D
> > RTC_PREFRAC = PREFRAC_RTC; //0x00001B00
> >
> > // Start RTC counters
> > RTC_CCR |= CCR_CLKEN;
> > RTC_ILR = ILR_RTCCIF;
> > }
> >
> >
> >
> >
> >
>


Reply by gsntone October 3, 20092009-10-03
Hi Wagner,

"Man, your are doing things WRONG. To solve it, use external clock with a 32.768KHz xtal."

With battery and external crystal for RTC your problem should be solved. (AFAIK my etteam-board has this 32.768 kHz crystal).
This option is the only way to keep your RTC running.

Hope this helps,
Gerd

--- In l..., "Wagner Loebel \(GMAIL\)" wrote:
>
> Hi everybody.
>
> I'm Wagner, I'm from Brazil. This is my first post here, I'm starting with ARM7 (I bought a board from ETT -Thailand with LPC2368) and I amazed with this uC, I always worked with COP8 from National (coding in assembly, crazy thing !!!) and recently with Z8Encore, but this ARM7 is impressive !
>
> Ok, I run a lot of samples in this board, web server, telnet, USB HID and MSD with SD-Card, etc etc. But now Its time to do some serious work...
>
> So I ported my codes from Z8Encore, put a LCD 16x2 to work, buzzer, leds blinking, bla bla bla. and... RTC. I run it from external clock and internal, both OK but I'm watching a strange behavior when running with internal clock. The RTC "stop to walk" during the time I maintain the reset switch pressed.
>
> Example:
>
> 1) RTC is running perfectly and shows 01:43:31 on LCD.
> 2) Then I press reset switch and continue with reset pressed for about 10 seconds;
> 3) When I release the reset switch, the RTC shows the same time (01:43:31) and THEN start to "walk" normally.
>
> The same happens when I power off the board, even with a battery on Vbat. No matter how many seconds, or minutes or hours it was powered off, the RTC dont lose the values because it have a small 3V battery on it Vbat pins but the RTC only return to count seconds, minutes and hours when the power is ON and not RESET. I read in the manual the entire chapter about RTC and others parts but not found any clue on how to solve it.
>
> I guess its happenning 'cause when the device is powered off the main oscilator is not running and there's any pulse of clock to make de RTC "walk", even with a backup battery in VBAT, is it right ?
>
> Below this is my initialization code. Can anyone give me some idea or tell me if there is something wrong or missing with my initialization code. Or to tell me: "Man, your are doing things WRONG. To solve it, use external clock with a 32.768KHz xtal"
>
> Thanks in advance,
>
> Wagner Loebel
>
>
> void RTCInit( void )
> {
> PCONP = PCONP | 0x200; //set bit PCRTC
>
> RTC_AMR = 0;
> RTC_CIIR = 0;
> //RTC_CISS = 0;
> RTC_CCR = 0x01; //0x11 ext.clock ;; 0x01 int.clock
> RTC_PREINT = PREINT_RTC; //0x0000016D
> RTC_PREFRAC = PREFRAC_RTC; //0x00001B00
>
> // Start RTC counters
> RTC_CCR |= CCR_CLKEN;
> RTC_ILR = ILR_RTCCIF;
> }
>
>
>
>
>

Reply by "Wagner Loebel (GMAIL)" October 3, 20092009-10-03
Hi everybody.

I'm Wagner, I'm from Brazil. This is my first post here, I'm starting with ARM7 (I bought a board from ETT -Thailand with LPC2368) and I amazed with this uC, I always worked with COP8 from National (coding in assembly, crazy thing !!!) and recently with Z8Encore, but this ARM7 is impressive !

Ok, I run a lot of samples in this board, web server, telnet, USB HID and MSD with SD-Card, etc etc. But now Its time to do some serious work...

So I ported my codes from Z8Encore, put a LCD 16x2 to work, buzzer, leds blinking, bla bla bla. and... RTC. I run it from external clock and internal, both OK but I'm watching a strange behavior when running with internal clock. The RTC "stop to walk" during the time I maintain the reset switch pressed.

Example:

1) RTC is running perfectly and shows 01:43:31 on LCD.
2) Then I press reset switch and continue with reset pressed for about 10 seconds;
3) When I release the reset switch, the RTC shows the same time (01:43:31) and THEN start to "walk" normally.

The same happens when I power off the board, even with a battery on Vbat. No matter how many seconds, or minutes or hours it was powered off, the RTC dont lose the values because it have a small 3V battery on it Vbat pins but the RTC only return to count seconds, minutes and hours when the power is ON and not RESET. I read in the manual the entire chapter about RTC and others parts but not found any clue on how to solve it.

I guess its happenning 'cause when the device is powered off the main oscilator is not running and there's any pulse of clock to make de RTC "walk", even with a backup battery in VBAT, is it right ?

Below this is my initialization code. Can anyone give me some idea or tell me if there is something wrong or missing with my initialization code. Or to tell me: "Man, your are doing things WRONG. To solve it, use external clock with a 32.768KHz xtal"

Thanks in advance,

Wagner Loebel
void RTCInit( void )
{
PCONP = PCONP | 0x200; //set bit PCRTC

RTC_AMR = 0;
RTC_CIIR = 0;
//RTC_CISS = 0;
RTC_CCR = 0x01; //0x11 ext.clock ;; 0x01 int.clock
RTC_PREINT = PREINT_RTC; //0x0000016D
RTC_PREFRAC = PREFRAC_RTC; //0x00001B00

// Start RTC counters
RTC_CCR |= CCR_CLKEN;
RTC_ILR = ILR_RTCCIF;
}