RTC update period

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

cross mob
urchc_1533771
Level 5
Level 5
5 likes given First like received First like given

Hi !

I want to put PSOC4-BLE to DEEPSLEEP but because I have RTC that keep time I need make interrupt each second.

Time to wake-up of BLE is ~0.5 sec so less 50% is used to sleep (some additional task exist).

So I think how to increment RTC not each sec but 5 sec ?

Are it's possible ?

0 Likes
6 Replies
Anonymous
Not applicable

The 500ms wakeup time is due to waiting for the clock to wakeup. You can reduce power usage and/or shorten the time using the low power application note iirc: http://www.cypress.com/documentation/application-notes/an92584-designing-low-power-and-estimating-ba...

To change the RTC to only update once every five seconds; Change the wakeup timer to 5 seconds, then change the RTC_Update() to be called 5 times, OR change the RTC_SetPeriod() to 5 seconds instead of 1 second to match the new timing interval.

0 Likes

Change the wakeup timer to 5 seconds, then change the RTC_Update() to be called 5 times,

It not possible to update RTC when DEEPSLEEP so I can't call RTC between wakeups.

Because it I asked how change the RTC_SetPeriod() to 5 second. API give this explanation :

void RTC_SetPeriod (uint32 ticks, uint32 refOneSecTicks)

The user needs to pass the period as a number of ticks and also a reference number of ticks taken by the same clock source for one second. For instance, for a 32 kHz clock source and RTC period of 100 ms, the "ticks" value is 3200 and the "refOneSecTicks" value is 32000.

How to assign it to 5 sec ?

0 Likes
Anonymous
Not applicable

Hmmmm; I guess I missed the one second requirement

But, I believe it should still work with some modifications:

Change your WDT to wake up at a 5-second interval as you desired.

Also, you will need to make sure the "Implement RTC update manually" checkbox in the RTC component IS CHECKED

Looking at the internal RTC code, you would either need to modify the component, or to just call the update 5 times at each 5-second interval.

Here is what your update each 5-second interval would look like:

void WDT_Interrupt_Handler_Five_Seconds() {RTC_Update() {

RTC_Update();

RTC_Update();

RTC_Update();

RTC_Update();

RTC_Update();

}

And, you will need to set the period on initialization like so:

RTC_SetPeriod(32000,32000); //This means that every single call to update will cause a unix increment and RTC status check for each second.

After calling RTC_Update() five times, it will have incremented the time by 5 seconds.

This is all according to:

/*******************************************************************************

* Function Name: RTC_Update

****************************************************************************//**

*

* \brief

*  This API updates the time registers and performs alarm/DST check.

*

*  This function increments the time/date registers by an input clock period.

*  The period is set by RTC_SetPeriod() API or WDT period selected for RTC

*  in the clocks configuration window (low frequency clocks tab) interface

*  every time it is called.

*

*  API is automatically mapped to the WDT's callback slot and period if the

*  configuration is as follows: 1) Option "Implement RTC update manually" in

*  the customizer is unchecked 2) One of WDTs is selected in the "Use for RTC"

*  panel of the low frequency clocks tab 3) Option "Implementation by IDE" is

*  selected in the "Timer (WDT) ISR" panel.

*

*  If option "Implement RTC update manually" is checked in the customizer or

*  option "None" is selected in the "Use for RTC" panel,it is the user's

*  responsibility: 1) to call this API from the clock ISR to be

*  used as the RTC's input 2) set the period of the RTC through

*  RTC_SetPeriod() API.

*

* \note Updates the Unix time register, updates the alarm and DST status.

*

*******************************************************************************/

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

Looks like it work but maximum 2 sec because CySysWdtSetMatch  match  param have Valid range [0-65535].

Attached project

0 Likes
Anonymous
Not applicable

If you cascade two of the WDTs together, you will get a longer timer; WDT 2 has a larger resolution with longer time periods, but only goes by base "2" for the timing.

You can cascade the WDTs together using the Project #3 example from here: http://www.cypress.com/documentation/code-examples/ce95400-watchdog-timer-reset-and-interrupt-psoc-4...

0 Likes

thanks ! I'll check.

0 Likes