- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't seem to get the RTC on my CY8CKIT-062-BLE to keep time. I thought the problem must be that I didn't have the battery, so I went and bought the recommended
SparkFun Electronics PRT-13854 3.7 V, lithium-ion polymer battery and connected it to J15, but that has not helped.
I'm working with the CE216825 - PSoC 6 MCU Real-Time Clock Basics code example. Here is a terminal session:
CE216825 - RTC Basics
Available commands
1: Get current time and date
2: Set new time and date
1
Current date and time
Date 06/05/20
Time 10:00:03
2
Enter new date (DD MM YY)
Enter new time in 24-hour format (hh mm ss)
11 05 20
Date and Time updated !!
Current date and time
Date 06/05/20
Time 11:05:20
1
Current date and time
Date 06/05/20
Time 11:05:33
Now I hit the reset button.
CE216825 - RTC Basics
Available commands
1: Get current time and date
2: Set new time and date
1
Current date and time
Date 06/05/20
Time 10:00:08
What happened to my setting?
Maybe I should try selecting the mysterious Time Reset on Start setting:
and try again:
CE216825 - RTC Basics
Available commands
1: Get current time and date
2: Set new time and date
1
Current date and time
Date 06/05/20
Time 11:00:58
2
Enter new date (DD MM YY)
Enter new time in 24-hour format (hh mm ss)
11 13 00
Date and Time updated !!
Current date and time
Date 06/05/20
Time 11:13:00
1
Current date and time
Date 06/05/20
Time 11:14:07
Now I hit the reset button.
CE216825 - RTC Basics
Available commands
1: Get current time and date
2: Set new time and date
1
Current date and time
Date 06/05/20
Time 11:00:02
That's better, but what happened to the minutes?
What am I doing wrong?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi CaKu_4284131,
The super capacitor needs to be charged to the required voltage initially before setting the SW7 switch to Super Cap mode.
This is achieved using the API Cy_SysPm_BackupSuperCapCharge(CY_SYSPM_SC_CHARGE_ENABLE);
You can use one of the backup registers present (retained as long as backup domain is powered) instead of using the flash to initialize the RTC block only once.
Please refer to the following thread that explains the steps in detail. There is also a project attached in the end for your reference.
Battery/Super Capacitor backup power / RTC
But if you are using a battery, then Cy_SysPm_BackupSuperCapCharge(CY_SYSPM_SC_CHARGE_ENABLE); should not be called. External circuitry should take care of battery charging.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi CaKu_4284131,
If you want the RTC to retain the time and date, you need to power VBACKUP pin separately (not VDDD) and possibly using a coin-cell battery. When device has active VDDD available, BACKUP domain (RTC) runs from VDDD and when VDDD is removed, it switches to VBACKUP supply.
In PSoC Creator, you need to select “Dedicated Supply” as the source for VBACKUP to avoid reset of RTC on POR or XRES.
Time reset on Start has to be used with PSoC Creator wrapper RTC_Start(). It has no influence on Cy_RTC_Init() PDL function.
Every time reset happens, you might be calling Cy_RTC_Init which resets the RTC values to default values. If you want to avoid that Cy_RTC_Init has to be called only once. So you can implement is the following logic:
if(rtc_initialialized == 0) //rtc_initialized is a custom variable in flash
{
Cy_RTC_Init(&RTC_config);
//rtc_initalised is true; write 1 in flash
}
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bragadeesh-
Where can I find the VBACKUP pin?
I spent some time reading the manuals, and I thought I'd try using Switch SW7 to set the Vbackup supply connection of PSoC 6 MCU to the super-capacitor. But then, I can't program the device:
Erasing of Main Flash...
Erasing of Main Flash Failed
EraseAll API returned: Error code 0x74CCA400: Unknown SROM status code
Error: dbg.M0023: There was an error while programming the device: PSoC Programmer reported error (100 - EraseAll API returned: Error code 0x74CCA400: Unknown SROM status code)
Is there a way around that?
I was able to get the RTC to keep time between resets by avoiding calling Cy_RTC_Init. But if I remove the USB power it goes back to
Date 01/01/00 Time 00:00:00.
-Carl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi CaKu_4284131,
The super capacitor needs to be charged to the required voltage initially before setting the SW7 switch to Super Cap mode.
This is achieved using the API Cy_SysPm_BackupSuperCapCharge(CY_SYSPM_SC_CHARGE_ENABLE);
You can use one of the backup registers present (retained as long as backup domain is powered) instead of using the flash to initialize the RTC block only once.
Please refer to the following thread that explains the steps in detail. There is also a project attached in the end for your reference.
Battery/Super Capacitor backup power / RTC
But if you are using a battery, then Cy_SysPm_BackupSuperCapCharge(CY_SYSPM_SC_CHARGE_ENABLE); should not be called. External circuitry should take care of battery charging.
Regards,
Bragadeesh
Bragadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Bragadeesh-
Thanks, I now have it working the way I want it to. I found the missing link in the thread that you referenced: I had to change External PMIC Output (under System settings) to Enabled.
To paraphrase someone famous, "Nobody knew [the RTC and VBACKUP] could be so complicated."
-Carl