Battery/Super Capacitor backup power / RTC

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

cross mob
TeMa_1467596
Level 5
Level 5
5 sign-ins 5 likes given First like received

I added the RTC component to my project which is running on a CY8CKIT-062-BLE board and start the RTC with...

RTCC_Start();

I can read the time from the RTC and it runs fine but Ievery time I power up, it starts from 00:00:00 and need it to keep tracking the time when the power is removed from the PCB.  I'm not sure what the default settings are on the CY8CKIT-062-BLE board regarding backup power and maybe this is all I need to fix? From the datasheet it seems that the default startup for the RTC is to not reset the time if it detects that it has already been set but clearly this doesn't survive a power cycle at present.

I'm also confused by many components that seem to have 2 sets of API commands, those starting with the component name like RTCC_Start() and then those that becgin Cy_...

Any help appreciated.

Ted

0 Likes
1 Solution

Here it is working.

- New project created based on RTC Basic example

- changed the vBackup Source to dedicated supply (post #3)

- Added the check of the reset cause to not overwrite the RTC (post #7)

- Enabled SuperCap charging (post #1)

- programmed the chip

- SW7 to CuperCap position

- Precharge of the SuperCap.

With this I could unplug the board now for almost 6 hours and the RTC was still counting.

View solution in original post

21 Replies
AchimE_41
Employee
Employee
10 sign-ins 5 sign-ins First comment on KBA

Hi Ted,

There is a SuperCap soldered on the board (the thing that looks like a coincell on the bottom). Next to it you have SW7 that can be used to select the powersource for the backup domain. But be aware that the super cap is charging very slowly, so a precharge by connection VDD to the SuperCap plus pole via a 100-200 resistor for a short time might be an option.

There is a SysCalls provided to enable the supercap Charging.

Cy_SysPm_BackupSuperCapCharge(CY_SYSPM_SC_CHARGE_ENABLE);

If the date is still reset with this option it has to be the software.

Regarding the 2 APIs:

The Cy_.. functions are the general functions provided by the driver (PDL). But to adapt to the previous (PSoC4/5LP) concept, where you only had functions generated based on the component alias, those wrappers were added/ generated as well for PSoC 6.

Personally I like that concept as it is easier to understand that you write to the "DEBUG_UART" rather than a simple "UART instance No 5"

regards,

Achim

Achim,

Thanks for the reply.  A few questions if I may...

1.     Please explain what you mean by "If the date is still reset with this option it has to be the software."

2.     Can the Cy_.. commands be mixed with the others safely or should I stick with one or the other?

I'll try the suggestions to get the backup battery running today.

Ted

0 Likes

One additional point to Achim's post - all PSoC Creator projects, by default, assume VBACKUP and VDDD are shorted together and sets the VBACKUP source in cywdr file as VDDD. This results in the backup domain resetting on every POR and XRES. If you have dedicated VBACKUP supply (can be configured in the kit as explained by Achim), then you can change the VBACKUP setting to Dedicated (as shown below). This makes sure the backup domain is not reset on every power-up or XRES.

pastedImage_1.png

Regards,

Meenakshi Sundaram R

Thanks for the suggestions, I tried adding the line...

Cy_SysPm_BackupSuperCapCharge(CY_SYSPM_SC_CHARGE_ENABLE);

into main and I also changed the system tab setting that says that Vbackup comes from a 'dedicated supply'. Then I set SW7 to the supercap position; on power up, the system reboots continuously which is not surprising as the PSoC Vdd 3.3 volts looks like this

DS1Z_QuickPrint3.png

I measured the voltage on the supercap and it was 0.9 volts so I used a 100 ohm resistor to charge it up to 2.9 volts but the reboot cycle and waveform are still the same. If I switch SW7 back, it runs just fine.  I think I'm missing something?

FWIW, I'm running the CY8KIT-062-BLE board by supplying 12V to J1 pin 1.

Any Ideas?

0 Likes

Did you mean you get the same reboot cycle and waveform once you supply 12V to J1 pin1? Have you ever tried to just supply VDDD through Type-C connector J10? The device should normally run as long as VDDD is valid, no matter what kind of power source to VBACKUP. 

0 Likes

I tested it, it makes no difference whether the power comes in via 12V to J1 pin 1 or just from the USB Type C connector; if I switch SW7 to the SuperCap position, I get that waveform and the never ending boot cycle.

My Code does get into main to the point of sending a welcome message out of the UART and then it reboots, maybe it's a watchdog timer or something?

0 Likes

I think there is an issue with the RTC driver, as it looks to me that the checkbox "Time Reset on Start" isn't doing anything. The Init function does not check such a parameter and just writes the time every time it is called

To prevent the time reset you either have to use Cy_RTC_IsExternalResetOccurred() or Cy_SysLib_GetResetReason() to determine the reset reason and check if you want to do the reset or not.

    if(Cy_RTC_IsExternalResetOccurred() == false)

    {

        if(Cy_RTC_Init(&RTC_config) != CY_RTC_SUCCESS)

        {

            /* If RTC initialization failed */

        }

    }

Alternatively you could use a variable stored in one of the backup registers (value is retained as long as VBAT is present) to signal that the RTC is configured.I have to look how this is done and come back with a code snipped. Easier than I thought, looks like it is working with regular register access (0xA119 is just a random key). LED is used to indicate when the RTC is updated.

    if(CY_GET_REG32(CYREG_BACKUP_BREG0)!= 0xA119)

    {

        Cy_GPIO_Clr(LED_0_PORT, LED_0_NUM);

        if(Cy_RTC_Init(&RTC_config) != CY_RTC_SUCCESS)

        {

            /* If RTC initialization failed */

        }

       

        CY_SET_REG32(CYREG_BACKUP_BREG0, 0xA119);

    }

I will create an internal bug report for the issue and sincerely apologize for the inconvenience this may have caused.

kind regards,

Achim

0 Likes
lock attach
Attachments are accessible only for community members.

Can you please try the attached project for test of backup domain?

I set the VBACKUP as power source of backup domain and comment the RTC initializing code in the project. This project is verified on 062-kit baord that the RTC still running during VDDD powered off. After re - power on, the time printed from UART can be used for verifying this.

Because the super cap on the board is charged very slowly, I bypassed it and introduced a power supplier fixed at 2.5V to for VBACKUP when it is tested.

0 Likes

My bad above with the "Time Reset on Start" it is working correctly, but of course only when using the generated functions (RTC_xxx ) instead of the generic ones we use in the RTC_Basics example.

The RTC_Start() function has also the above reset handling already included.

0 Likes

Guys,

I did some more tests with another 062-kit board and the behavior is the same.  I think this may be an issue associated with the circuitry that charges the SuperCap or the combination of supplies and switch settings.  If I charge up the Cap and leave SW7 in the non-SuperCap position (away from the SuperCap), my code works and if I disconnect power, count to 10, and reapply power. the time is not reset.

If I put SW7 in the SuperCap position with power off and then connect power (USB3 plugged into a USB 2 port in my case), the board does not power up but when I meter Vddd, I find that it runs up to 1.8 volts only; disconnect power, move SW7 to the non-SuperCap position, count to 10, and reapply power, Vdd comes up as 3.3 volts.

Looking at the schematic, it looks like P0[5] on the PSoC 6 is an output that causes U11 to feed P6_PMIC_EN_OUT to go to 1.8V and that is routed through SW7 becoming PMIC_EN that feeds into U6 presumably causing the adjustable (1.8 - 3.3V) regulator to come on.  Maybe there's a logic loop issues that causing my power up sequence above?

Here's the summary of my settings.

1. My target PSoC 6 Vddd is 3.3 volts.

2. For the purposes of this investigation, assume that I'm powering the 062-Kit board from the USB Type C connector only and plugging that into a USB port (it behaves the same if I feed +12V into J1)

3. It is my design intention that the board will only be supplied with +12V through J1 so the Kitporg2 should not be controlling Vbackup

Any more ideas?

0 Likes

Oh and I have a Rev 11 and 2 Rev 13 CY8CKIT-062-BLE PCBs, the issue has been tested on one Rev 11 and one Rev 13 PCB.

Also I tried this.

1. My white switch is set to center (+3.3V position)

2. Connect a voltmeter to measure between P6. Vdd (a via on the PCB right next to the SuperCap -ve terminal) and ground, I get +3.3V

3. Move SW7 to the SuperCap position and the measurement changes to +1.59V in my case and my code stops running

4. Move SW7 away from the SuperCap position and the measured voltage changes to +3.3V and my code starts running again

5. The observed voltages associated with the SW7 position are the same if SW7 is moved before power is applied.

0 Likes

Here it is working.

- New project created based on RTC Basic example

- changed the vBackup Source to dedicated supply (post #3)

- Added the check of the reset cause to not overwrite the RTC (post #7)

- Enabled SuperCap charging (post #1)

- programmed the chip

- SW7 to CuperCap position

- Precharge of the SuperCap.

With this I could unplug the board now for almost 6 hours and the RTC was still counting.

aceh,

Can you upload your project please and I'll try it?

Thanks,

Ted

0 Likes
lock attach
Attachments are accessible only for community members.

Sure, Project attached.

0 Likes

Hmmm, that project didn't work at all, no output on the UART.

0 Likes

Sounds strange...

The example only sends one string on power up/reset, to get the time you have to sent ASCII '1' through the terminal.

Output should look like the following.

- Red X the device was reset

- Blue X the device was disconnected (no init message as the UART connection was lost)

pastedImage_1.png

0 Likes

Looking at the schematic, it looks like P0[5] on the PSoC 6 is an output that causes U11 to feed P6_PMIC_EN_OUT to go to 1.8V and that is routed through SW7 becoming PMIC_EN that feeds into U6 presumably causing the adjustable (1.8 - 3.3V) regulator to come on.  Maybe there's a logic loop issues that causing my power up sequence above?


Thank you, @ted_1467596 and @aceh for helping me get this working.  I had added the supercap charging to the RTC example project, and was having the same brownout issues, even when I set the vBackup source to Dedicated.  Opening up @aceh's project, I saw that the External PMIC Output (under System settings) had been enabled in his project.

It seems that the PMIC doesn't get enabled if that setting is incorrect, and that results in the brownouts.

After that, there was just the matter of modifying the reset code in rtc_task.c to check the reason for the reset.

    if(Cy_RTC_IsExternalResetOccurred() == false) {

        rtcApiResult = Cy_RTC_SetDateAndTimeDirect(TIME_AT_RESET);

After that, the example works fine.

kategray/CE222604_RTC_CTC · GitHub

Kate,

That looks like what my issue has been all along!  You fixed my problem, not vice versa Thanks

I looked at my version of CE222064 and it has the PMIC Output disabled too.  Can you post a screen shot of what your system settings are please?

Also, if an External Rest has occurred, doesn't that mean that the time will have been lost?  Your code says that if ExternResetOccurred is false then you set the time to TIME_AT_RESET - I'm suggesting it should be true???

Ted

[EDIT] I think it's working, I changed the External PMIC Output (under System settings) had to enabled and now, with the switch thrown towards the SuperCap, it now runs and the SuperCap voltage is coming up but very slowly (like it will take maybe 20 minutes for it to reach 3.3 volts) - hmm seems to be stuck at 1.6 volts.

0 Likes

"I looked at my version of CE222064 and it has the PMIC Output disabled too.  Can you post a screen shot of what your system settings are please?"

settings.png

"Also, if an External Rest has occurred, doesn't that mean that the time will have been lost?  Your code says that if ExternResetOccurred is false then you set the time to TIME_AT_RESET - I'm suggesting it should be true???"

If you right click on the function in PSoC Creator, and choose go to declaration, the documentation is in the declaration.

"

* The function checks the reset cause and returns the Boolean result.

*

* \return

* True if the reset reason is the power cycle and the XRES (external reset) <br>

* False if the reset reason is other than power cycle and the XRES."

In other words, I'm checking to see if the cause is an external reset or power cycle.  If that's the case, then I want it to keep the time.  If it crashed, I want it to reset the time.

" hmm seems to be stuck at 1.6 volts."

If you look at the schematic, I think you will see why.

http://www.cypress.com/file/420836/download

It looks like the 74LVCE1G126W5-7 chip is driving the backup supply using the 1v8 rail.

There's still plenty of power - I just finished a 24 hour test with the example and the supercap.  It lost 2 minutes, but otherwise worked fine.

Thanks, that all makes sense now.

The truth is out there, but it isn't in the documentation (or at best it's buried in there).

[EDIT]

I ordered some 1.2 AHr batteries with JST-PH connectors from Hobbyking (https://hobbyking.com/en_us/turnigy-1200mah-1s-1c-lipoly-w-2-pin-jst-ph-connector.html?___store=en_u... ) and then I got the S2B-PH-K-S(LF)(SN) JST connectors from Digikey (455-1719-ND) and fitted them to the PCB.

When I plug the battery in, the board comes on but now I'm trying to figure out what, if anything, the system does to protect a battery if it runs down.  I haven't tested this much yet but I observed that:

1.     If the battery is connected, the board runs up

2.     If the battery is fitted and the main power is then provided (in my case +12V via J1 pin 1), then U14 seems to charge the battery as the voltage rises slightly - going to test this with an ammeter.

3.     I think (hope) that the SuperCap can also be running along with the battery to provide total power loss backup for the RTCC

This isn't covered very well in the documentation and what I'm suggesting above is from working through the schematic.  The batteries I'm using have a small protection PCB fitted so maybe they will protect themselves by powering off when the battery gets below a certain voltage - again I'll try to test and share here - but then that would mean that the system would need to monitor the battery voltage and do a graceful shutdown preemptively.

Some input from Cypress on this topic would be appreciated.

0 Likes

More testing reveals:

The whole battery & charging circuit seems to be designed around the USB Type C, if the USB type C is plugged in, the battery is charged but not when the type C is unplugged.  My power supply is derived from +12V via J1 pin 1 and when I provide this supply the onboard buck/boost regular (U21) runs and that provides VCC_5V which is supplied to U14 pin 18/19 so I think I need to figure out a way to make nCE (U14 pin 4) go low to charge the battery but I'm not certain.

0 Likes