Problem using Internal RTC LPC1768/69

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

Problem using Internal RTC LPC1768/69

Jump to solution
2,656 Views
abhinavdubey
Contributor II

Hi,

I'm trying to program internal RTC of LPC1768 controller, When I run my program I get different  (random) date and time on different LPC1768 boards (I'm trying on 3 different boards). i.e. on one board date is :- 1/2/1878, on 2nd board 30/11/3036 etc.  I never get date and time which I have defined in my program.

What could be the issue, pls help.

Thanks

Abhinav

Tags (1)
0 Kudos
1 Solution
2,025 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Abhinav,

If the VBAT is supplied, the RTC would keep working even main power is off.

After had a brief look through the demo, I think I had found the root cause of the issue.

The RTC would be active when the main power is off, and it can cause POR reset and processor will boot-up immediately when the supply power recovers.

So in this cycle, you shouldn't initialize the RTC module again, or it will change the value of Time counter registers.

I'd recommend that you can declare a flag value in the particular address of the Flash, and the demo will determine to initialize the RTC module or not by relying to the value of flag.

Have a great day,
Ping

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
9 Replies
2,025 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

According to statement, the real time value became random even you had set the initial value, isn't it right?

I was wondering if you can share the demo, then I can run it on my board to replicate the issue.

I think it can help me to figure out the issue.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,025 Views
abhinavdubey
Contributor II

Hi,

Thanks for reply.

Pls find attached code,

Real time doesn’t vary, I never get real time values even close to real time, I get random date and time, pls have a look at attached image file.

Thanks

Abhinav

0 Kudos
2,025 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Abhinav,

I didn't find that you initialize the set of Time counter registers (Fig 1) in your demo, and I think it's the root cause of the issue.

So I'd highly recommend you to refer to the rtc demo in the LPCxpresso_1769's sample demo whose downloading link is below.

I've also attached some codes which is used to configure the set of Time counter registers.

2016-09-30_17-16-13.jpg

Fig 1

    /* Set current time for RTC 2:00:00PM, 2012-10-05 */
    FullTime.time[RTC_TIMETYPE_SECOND]  = 0;
    FullTime.time[RTC_TIMETYPE_MINUTE]  = 0;
    FullTime.time[RTC_TIMETYPE_HOUR]    = 14;
    FullTime.time[RTC_TIMETYPE_DAYOFMONTH]  = 5;
    FullTime.time[RTC_TIMETYPE_DAYOFWEEK]   = 5;
    FullTime.time[RTC_TIMETYPE_DAYOFYEAR]   = 279;
    FullTime.time[RTC_TIMETYPE_MONTH]   = 10;
    FullTime.time[RTC_TIMETYPE_YEAR]    = 2012;

    Chip_RTC_SetFullTime(LPC_RTC, &FullTime);

LPCxpresso_1769's sample demo:

LPCOpen Software for LPC17XX|NXP 

Have a great day,
Ping

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,025 Views
abhinavdubey
Contributor II

Hello Sir,

Problem resolved, Now I can see same date and time what I’ve set in program. Now new problem raised, When I power off my device it doesn’t able to continue, it starts executing from initial time and date what I’ve set in my program. I don’t trust my hardware, could you pls check it at your end on your hardware??? Or if its firmware problem pls let me know.

Waiting for reply.

Thanks

Abhinav

0 Kudos
2,025 Views
volkeroth
Contributor II

But you still supply the Vbat pin which keeps the RTC domain alive, do you?

I mean, when you completely power off (including the Vbat pin), how would the RTC continue to run?

0 Kudos
2,025 Views
abhinavdubey
Contributor II

Hi,

Sorry for incomplete information.

I keep VBAT supply +3V, power off means I remove supply for controller only. VBAT is supplied and RTC section is alive.

Pls check it on your hardware.

Thanks

Abhinav

0 Kudos
2,024 Views
volkeroth
Contributor II

As jemeryzhou pointed out, initializing the RTC after each power on reset will of course overwrite its values.

One solution to detect that the RTC was initialized would be to write some "magic" word like 0xdeadbeef as marker to one of the battery backed general purpose registers 0 to 4 (GPREG0 to GPREG4 - addresses 0x4002 4044).
to 0x4002 4054). If this word is still there after a reset, the RTC is still initialized and doesn't need to be set up again. If the word is not there, you need to initialize the RTC and then write the magic word to GPREGx.

0 Kudos
2,026 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Abhinav,

If the VBAT is supplied, the RTC would keep working even main power is off.

After had a brief look through the demo, I think I had found the root cause of the issue.

The RTC would be active when the main power is off, and it can cause POR reset and processor will boot-up immediately when the supply power recovers.

So in this cycle, you shouldn't initialize the RTC module again, or it will change the value of Time counter registers.

I'd recommend that you can declare a flag value in the particular address of the Flash, and the demo will determine to initialize the RTC module or not by relying to the value of flag.

Have a great day,
Ping

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
2,024 Views
abhinavdubey
Contributor II

Hello Sir,

Thanks for your valuable reply.

Silly mistake!!, I should have noticed that earlier. Its working fine. Thank you so much for all your valuable support. I’ll get back if any other issue comes.

Thanks

Abhinav

0 Kudos