How to use internal RTC in PSOC 5LP

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
PAB
Level 2
Level 2
First like given Welcome!

I had made a code to display time on LCD and get time through internal RTC  but when i reset the controller or reprogram the controller the time gets to its original preset setting on RTC.

please help with any example code and schematic.

thanks in advance.@

0 Likes
1 Solution
Anonymous
Not applicable

The RTC retains data if you make it retain data. When you normally assign any variable data while the microcontroller is running, it it saved in RAM. When power goes off then the RAM powers down. If you want the data to remain after a reset then you have to store it in a non-volatile place like flash, EEPROM or external memory. As far as I know, the RTC component does not have this automatically.

You can also try the CY_NOINIT  as Evgeniy suggested but I personally have never used this system.

Also I am old enough to remember systems where the not initializing variables would ensure that you get garbage results. So I have a few mental blocks about NOINIT.

View solution in original post

0 Likes
11 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The RTC component is a pure software solution. So you need to set the time and date aftera reset.

Bob

How to do that i had no idea. can you give me an example code of RTC on PSOC 5LP.

thanks.

paras

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When you right-click onto the RTC component and select for code examples you are presented with more than 10 example projects. Most difference from PSoC5 to PSoC4 is the source of the interrupt tick used to advance time count.

Bob

0 Likes
Anonymous
Not applicable

Your code will look something like this:-

void RTC_Startup_init()

{

    Start.Sec = 00u;

    Start.Min = 00u;

    Start.Hour = 00u;

    Start.DayOfMonth = 01u;

    Start.Month = 01u;

    Start.Year = 2018u;

    RTC_WriteTime(&Start);

    RTC_WriteIntervalMask(RTC_INTERVAL_SEC_MASK);

   

    RTC_Start();

    //RTC_Enable();

   // RTC_SetPeriod(32768,32768);

   

   

}

If you set the time at the start of the reset via UART or any other input then it will work.

If you want a quick and dirty solution, use a DS1307 IC over I2C , it holds on to its time sample even after reset.

0 Likes
PAB
Level 2
Level 2
First like given Welcome!

Is there any way to retrive time after reset  in PSOC.?

0 Likes
Anonymous
Not applicable

You can enter the data manually via UART or keypad everytime the uC starts or you can try writing active time to EEPROM every second. And then read the EEPROM data as starting time for the UC.

0 Likes

and another way  How to use CY_NOINIT?

0 Likes

i  set the RTC once but again when we re program PSOC or reset the controller it does not retain the time in RTC. rtc must retain the time.

0 Likes
Anonymous
Not applicable

The RTC retains data if you make it retain data. When you normally assign any variable data while the microcontroller is running, it it saved in RAM. When power goes off then the RAM powers down. If you want the data to remain after a reset then you have to store it in a non-volatile place like flash, EEPROM or external memory. As far as I know, the RTC component does not have this automatically.

You can also try the CY_NOINIT  as Evgeniy suggested but I personally have never used this system.

Also I am old enough to remember systems where the not initializing variables would ensure that you get garbage results. So I have a few mental blocks about NOINIT.

0 Likes
PAB
Level 2
Level 2
First like given Welcome!

yes exectly we need to store the time / rtc data into a non-volatile memory. but is there any way to find the period  between the resets/ power down.

like i  start RTC it shows x timing, i powered down it and detected power down and saved the time in EEPROM, after 10 minutes i powered it.

i want that some how i find this time between power downs so that i can get the timing back.

thanks

Paras

0 Likes
Anonymous
Not applicable

As far as I know, it is all but impossible to find out "off time" with the internal RTC.

0 Likes