Infineon AN220190 User Manual

Please read the Important Notice and Warnings at the end of this document 002-20190 Rev. *D
www.infineon.com page 1 of 47 2020-12-15
AN220190

About this document

Scope and purpose
This application note describes how to use the real-time clock (RTC) in Traveo II family MCUs.
Intended audience
This document is intended for anyone who uses the RTC of the Traveo II family.

Table of contents

About this document ....................................................................................................................... 1
Table of contents ............................................................................................................................ 1
1 Introduction .......................................................................................................................... 2
1.1 Features of RTC ....................................................................................................................................... 2
2 Operation Overview ............................................................................................................... 3
2.1 Basic RTC Settings ................................................................................................................................... 4
2.1.1 Use Case ............................................................................................................................................. 4
2.1.2 Initializing the RTC Function .............................................................................................................. 4
2.1.3 Configuring the RTC Function ............................................................................................................ 6
2.1.4 Example Program to Configure RTC Function in Driver Part .......................................................... 10
2.2 Reading TIME and DATE ........................................................................................................................ 16
2.2.1 Use Case ........................................................................................................................................... 16
2.2.2 Reading the RTC Values ................................................................................................................... 17
2.2.3 Items Read for RTC Value ................................................................................................................. 18
2.3 Updating TIME and DATE ...................................................................................................................... 20
2.3.1 Use Case ........................................................................................................................................... 20
2.3.2 Updating the RTC Values (For Example, Adjusting DST) ................................................................ 21
2.3.3 Example Program to Update RTC Values in Driver Part.................................................................. 23
2.4 Calibrating WCO .................................................................................................................................... 24
2.4.1 Use Case ........................................................................................................................................... 24
2.4.2 Capturing the WCO Waveform ......................................................................................................... 24
2.4.3 Example Program to Capture WCO Waveform in Driver Part ......................................................... 29
2.5 Measuring the Difference Between the WCO and an Ideal Waveform................................................. 30
2.5.1 Example Program to Measuring the WCO Waveform in Driver Part ............................................... 34
2.5.2 Confirming the Accuracy of the WCO Frequency after Calibration ................................................ 36
2.5.3 Example Program to Confirm Accuracy of WCO Frequency after Calibration in Driver Part ........ 40
Glossary ....................................................................................................................................... 42
Related Documents ........................................................................................................................ 44
Revision history............................................................................................................................. 46
2 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Introduction

1 Introduction

The RTC in Traveo II family has four features; RTC, Alarm, Calibration, and Backup registers.
The RTC feature keeps track of the current time, year, month, date, day-of-week, hour, minute, and second accurately. The alarm feature can generate interrupts to the CPU with programable setting. The calibration feature can correct a frequency error of the WCO and Low-power external crystal oscillator (LPECO). The backup registers can keep user data in any power mode.
This application note:
Explains how to update the time of the RTC registers
Describes how to read the time from the RTC registers
Explains the functions of RTC in series
Shows how to set up the RTC function and calibrate the WCO
To understand the functionality described and terminology used in this application note, see the Real-Time Clock chapter of the Architecture Technical Reference Manual (TRM).

1.1 Features of RTC

The following are the features of RTC:
Fully-featured RTC function
Year/Month/Date, Day-of-Week, Hour: Minute: Second fields (All fields are integer values)
Supports both 12-hour and 24-hour formats
Automatic leap-year correction until 2400
Configurable alarm function
Alarm on Month/Date, Day-of-Week, Hour: Minute: Second fields
Two independent alarms
Calibration for 32.768-kHz WCO and 4-MHz to 8-MHz LPECO
Calibration waveform output
Supports 512 Hz, 1 Hz, and 2 Hz
Backup registers
Note: See the device-specific datasheet to confirm whether LPECO is present.
3 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview

2 Operation Overview

The RTC function keeps track of the current time accurately up to seconds and therefore, can be used as an accurate time source in automotive applications. This application note describes clock screens in vehicles as a sample use case. The time on the clock screen is updated accurately and periodically.
Figure 1 shows the RTC function block diagram and an example of the user system.
Clock Screen In a Vehicle
WCO
Traveo II
Traveo II Device
CPU
AM
RTC Function
RTC Field
Alarm Field
Config Field
RAM
User Buffer
WCO Logic
PORT
Interrupt
/ /
Tues
RTC_CAL Pin
AHB-Lite Bus
Use Register
RTC Field
Alarm Field
Config Field
RTC Register
V
DDD
Calibration Waveform
Figure 1 Example Structure of the User System using RTC Function
The RTC function block consists of user registers, RTC registers, and WCO and LPECO. The RTC function interfaces with the CPU and other sub-systems via the AHB-Lite bus interface. The WCO or LPECO can generate the required clock with the help of an external crystal or external clock inputs. The RTC function has a programmable alarm function, which can generate interrupts to the CPU.
For updating and displaying the current time on the clock screen of vehicles, the RTC function is generally used with periodic interrupts. The CPU and the RTC function are connected via an AHB-Lite interface, which provides firmware access interface.
The CPU reads the current time from the RTC function, stores the real-time data in the user buffers, which are local variables assigned in RAM, and outputs the real-time data to the external clock screen. Moreover, the RTC function can also output a calibration waveform.
User registers and the RTC registers have RTC fields, Alarm fields, and Config fields. Software can access the user registers. A specific writing operation updates the RTC registers with the user registers. A specific read operation copies data from the RTC registers to the user registers. See the Architecture TRM and Register TRM for the details on RTC fields, Alarm fields, and Config fields.
The WCO device and logic, the LPECO and logic, and the RTC function run on VDDD, which is a continuous power supply. Therefore, the RTC function runs in all power modes, and the function continuously keeps track of the current time.
There are four operations that keep track of the current time:
1. Initializing RTC function including interrupts
2. Reading time and date
3. Updating time and date
4. Calibrating WCO
4 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Before using the RTC function, an initialization routine needs to be executed. The initializing operation includes the alarm interrupt setting. The interrupt is caused by the alarm function which has fields corresponding to the RTC field registers. Basic RTC Settings provides the example setting for generating interrupts every 30 seconds with two alarm functions.
To display the current time on the clock screen of a vehicle, the CPU reads a current time from the RTC field registers. Reading TIME and DATE provides an example to read the current time from the RTC field.
There are instances where you might have to update the RTC fields registers, for example for Daylight Saving Time (DST). For DST, the Hour field needs to be updated. Updating TIME and DATE provides an example to the update the current time of the RTC field.
You can use ILO, CLK_LF, WCO, or LPECO as a source clock for the RTC function. However, WCO or LPECO is recommended as it is more accurate. Calibrating WCO provides an example to calibrate the time of the RTC function.

2.1 Basic RTC Settings

This section describes the operation of the RTC function with the following assumptions.
This section also explains how to configure the RTC based on a use case using the Sample Driver Library (SDL) provided by Cypress. The code snippets in this application note are part of SDL. See Other References for the SDL.
SDL basically has a configuration part and a driver part. The configuration part mainly configures the parameter values for the desired operation. The driver part configures each register based on the parameter values in the configuration part.

2.1.1 Use Case

This section explains an example of the RTC function using the following use case. This use case shows how to initialize items such as input clock, time, and date to enable the RTC function. Also, this use case enables the ALARM function. When the ALARM setting time and RTC time match, an interrupt is generated.
Use case:
Source clock: Internal Low-speed oscillator (ILO)
Setting year: 2019
Setting month: August
Setting date: 21
Setting day of week: Monday
Setting time: 12:00:00
Setting HR mode: 24HR
ALARM1: Every 0 seconds
IRQ number for ALARM1: 3

2.1.2 Initializing the RTC Function

The following example initializes the RTC function after the power on reset. Once the RTC function is initialized, there is no need to reinitialize the RTC function even if the device has switched power modes.
Figure 2 shows an example flow to configure the basic RTC settings.
5 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Start
Set Time and Date Parameters
in Temporary Structure
(1)
(2)
(3)
(4)
(5)
(6)
(7)
Set WRITE bit for Writing
ALARM1 Time and Date
Set WRITE Bit for Writing Time
and Date
Set Time and Date in the
BACKUP register
Set ALM1_TIME and
ALM1_DATE
Clear WRITE Bit
Set ALARM1 Time and Date
Parameters in Temporary
Structure
End
(8)
Clear WRITE Bit
(9)
Select Source Clock as ILO
Set Interrupt Mask
(10)
Set Interrupt
Clear Interrupt
(11)
(12)
Start
End
Clear Interrupt Flag for ALARM1
Interrupt routineMain routine
(13)
Figure 2 Example Flow to Configure Basic RTC Settings and Interrupt Routine
6 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
The following procedure shows the basic setup procedure for the RTC function:
1. Set interrupt.
2. Select the source clock as ILO:
Write BACKUP_CTL.CLK_SEL = CY_RTC_CLK_SRC_ILO_0 (ILO)
3. Set the time and date parameters in temporary structure:
TIME parameter (Second=0, minute=0, hour=12, HR mode=0(24HR), day of week=1(Monday)) DATE parameter (date=21, month=8, year=19 (2019))
4. Set the WRITE bit for writing the time and date:
Write BACKUP_RTC_RW.WRITE = ‘1’
5. Set the time and date for the BACKUP_RTC_TIME and BACKUP_RTC_DATE registers:
Write BACKUP_RTC_TIME = time parameter Write BACKUP_RTC_DATE = date parameter
6. Clear the WRITE bit to update the date and time in the RTC registers:
Write BACKUP_RTC_RW.WRITE = ‘0’
7. Clear the interrupt.
8. Set the interrupt mask.
9. Set the ALARM1 time and date parameters in temporary structure.
10. Set the WRITE bit for writing the ALARM1 time and the date.
11. Set the ALARM1 time and date for the BACKUP_ALM1_TIME and BACKUP_ALM1_DATE registers:
When the RTC fields and the alarm fields match, an interrupt occurs. Write BACKUP_ALM1_TIME = ALARM1 time parameter (0 second) Write BACKUP_ALM1_DATE = ALARM1 date parameter (No ALARM in Date parameter)
12. Clear the WRITE bit to update the date and time in the RTC registers:
Write BACKUP_RTC_RW.WRITE = ‘0’
13. When the ALARM1 interrupt occurs, clear the interrupt flag.
The alarm function generates an interrupt when the RTC fields and the alarm fields match.
If you want to set the alarm every 30 seconds, you need to set two alarms.
For details on the interrupt setting procedure, see the Interrupt and Fault Report Structure section in AN219842 [5].

2.1.3 Configuring the RTC Function

Table 1 lists the parameters and Table 2 lists the functions of the configuration part in SDL for RTC and ALARM
settings.
7 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Table 1 List of RTC and ALARM Setting Parameters
Parameters
Description
Value
RTC_config.sec
Calendar seconds, 0-59
RTC_INITIAL_DATE_SEC = 0ul
RTC_config.min
Calendar minutes, 0-59
RTC_INITIAL_DATE_MIN = 0ul
RTC_config.hour
Calendar hours, value depending on 12/24HR mode
RTC_INITIAL_DATE_HOUR = 12ul
RTC_config.hrMode
Select 12/24HR mode: 1=12HR, 0=24HR CY_RTC_12_HOURS = 1ul, CY_RTC_24_HOURS = 0ul
RTC_INITIAL_DATE_HOUR_FORMAT = CY_RTC_24_HOURS
RTC_config.dayOfWeek
Calendar Day of the week, 1-7 I You can define the values, but it is
recommended to set 1=Monday.
RTC_INITIAL_DATE_DOW = 1ul
RTC_config.date
Calendar Day of the Month, 1-31 Automatic Leap Year Correction
RTC_INITIAL_DATE_DOM = 21ul
RTC_config.month
Calendar Month, 1-12
RTC_INITIAL_DATE_MONTH = 8ul
RTC_config.year
Calendar year, 0-99
RTC_INITIAL_DATE_YEAR = 19ul
alarm.sec
Alarm seconds, 0-59
0ul
alarm.sec_en
Alarm second enable: 0=ignore, 1=match
CY_RTC_ALARM_ENABLE = 1ul
alarm.min
Alarm minutes, 0-59
0ul
alarm.min_en
Alarm minutes enable: 0=ignore, 1=match
CY_RTC_ALARM_DISABLE = 0ul
alarm.hour
Alarm hours, value depending on 12/24HR mode
0ul
alarm.hour_en
Alarm hour enable: 0=ignore, 1=match
CY_RTC_ALARM_DISABLE = 0ul
alarm.dayOfWeek
Calendar Day of the week, 1-7 You can define the values, but it is
recommended to set 1=Monday
1ul
alarm.dayOfWeek_en
Alarm Day of the Week enable: 0=ignore, 1=match
CY_RTC_ALARM_DISABLE = 0ul
alarm.date
Calendar Day of the Month, 1-31 Automatic Leap Year Correction
1ul
alarm.date_en
Alarm Day of the Month enable: 0=ignore, 1=match
CY_RTC_ALARM_DISABLE = 0ul
alarm.month
Alarm Month, 1-12
1ul
alarm.month_en
Alarm Month enable: 0=ignore, 1=match
CY_RTC_ALARM_DISABLE = 0ul
alarm.alm_en
Master enable for alarm 1. 0: Alarm 1 is disabled. Fields for date and
time are ignored. 1: Alarm 1 is enabled. If none of the date
and time fields are enabled, this alarm triggers once every second.
CY_RTC_ALARM_ENABLE = 0ul
8 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Table 2 List of RTC and ALARM Setting Functions
Functions
Description
Value
Cy_Rtc_clock_source (clock_source)
Set the RTC input clock source Clock source: Input clock
source
CY_RTC_CLK_SRC_ILO_0
Cy_Rtc_Init (*config)
Initialize the RTC driver and return the RTC register address
config: RTC configuration structure address
&RTC_config
Cy_Rtc_SetDateAndTime (*dateTime)
Set the time and date values to the RTC_TIME and RTC_DATE registers.
dateTime: RTC configuration structure address
config
Cy_Rtc_ConstructTimeDate (*timeDate, time, date)
Returns Integer time and Integer date in the format used in APIs from individual elements passed.
timeDate: Structure address of time and date
time: Time configuration structure address for the RTC_TIME register set
date: Date configuration structure address for the RTC_TIME register set
dateTime, &tmpTime, &tmpDate
Cy_Rtc_ClearInterrupt (interruptMask)
Clear the RTC interrupt interruptMask: The bit mask of
interrupt to clear
CY_RTC_INTR_ALARM1=0x1ul
Cy_Rtc_SetInterruptMask (interruptMask)
Set the RTC interrupt interruptMask: The bit mask of
interrupt to set
CY_RTC_INTR_ALARM1=0x1ul
Cy_Rtc_SetAlarmDateAndTime (alarmDateTime, alarmIndex)
Sets alarm time and date values into the ALMx_TIME and ALMx_DATE registers
alarmDateTime: The alarm configuration structure
alarmIndex: The alarm index to be configured
&alarm, CY_RTC_ALARM_1=0ul
Cy_Rtc_ConstructAlarmTimeDate (*alarmDateTime, *alarmTime,
*alarmDate)
Returns the Integer time and Integer date in the format used in APIs from individual elements passed for alarm
alarmDateTime: Structure address of alarm time and date
alarmDateTime, &tmpAlarmTime, &tmpAlarmDate
9 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Functions
Description
Value
alarmTime: Alarm time configuration structure address for the ALMx_TIME register set
alarmDate: Alarm date configuration structure address for the ALMx_DATE register set
_VAL2FLD (field, value)
Mask and shift a bit field value for use in a register bit range.
Field: Name of the register bit field.
Value: Value of the bit field. This parameter is interpreted as an uint32_t type.
-
Code Listing 1 shows an example program of configuration part for the RTC function.
The following description will help you understand the register notation of the driver part of SDL:
BACKUP->unRTC_TIME register is the BACKUP_RTC_TIME register mentioned in the Register TRM. Other
registers are also described in the same manner.
See cyip_backup_v3.h under hdr/rev_x/ip for more information on the union and structure representation of registers.
Code Listing 1 Example Program to Configure RTC
cy_stc_rtc_config_t const RTC_config = { /* Initiate time and date */ .sec = RTC_INITIAL_DATE_SEC, .min = RTC_INITIAL_DATE_MIN, .hour = RTC_INITIAL_DATE_HOUR, .hrMode = RTC_INITIAL_DATE_HOUR_FORMAT, .dayOfWeek = RTC_INITIAL_DATE_DOW, .date = RTC_INITIAL_DATE_DOM, .month = RTC_INITIAL_DATE_MONTH, .year = RTC_INITIAL_DATE_YEAR, }; cy_stc_rtc_alarm_t const alarm = { .sec = 0ul, .sec_en = CY_RTC_ALARM_ENABLE, .min = 0ul, .min_en = CY_RTC_ALARM_DISABLE, .hour = 0ul, .hour_en = CY_RTC_ALARM_DISABLE, .dayOfWeek = 1ul,
.dayOfWeek_en = CY_RTC_ALARM_DISABLE,
.date = 1ul, .date_en = CY_RTC_ALARM_DISABLE, .month = 1ul, .month_en = CY_RTC_ALARM_DISABLE, .alm_en = CY_RTC_ALARM_ENABLE };
int main(void) { SystemInit();
__enable_irq(); /* Enable global interrupts. */
Cy_GPIO_Pin_Init(USER_LED_PORT, USER_LED_PIN, &user_led_port_pin_cfg);
Configure initial time and date parameters. See Table 1.
Configure ALARM1 time and date parameters. See Table 1 .
10 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 1 Example Program to Configure RTC
cy_stc_sysint_irq_t irq_cfg = (cy_stc_sysint_irq_t) { .sysIntSrc = srss_interrupt_backup_IRQn, .intIdx = CPUIntIdx0_IRQn, .isEnabled = true, }; Cy_SysInt_InitIRQ(&irq_cfg); Cy_SysInt_SetSystemIrqVector(irq_cfg.sysIntSrc, RTC_Handler); NVIC_SetPriority(CPUIntIdx0_IRQn, 3ul); NVIC_ClearPendingIRQ(CPUIntIdx0_IRQn); NVIC_EnableIRQ(CPUIntIdx0_IRQn);
/* Set the ILO_0 as the clock source to the RTC block */
Cy_Rtc_clock_source(CY_RTC_CLK_SRC_ILO_0);
/* Wait for alarm to be set */ while(Cy_Rtc_Init(&RTC_config) != CY_RET_SUCCESS);
/* Clear any pending interrupts */
Cy_Rtc_ClearInterrupt(CY_RTC_INTR_ALARM1);
/*Configures the source (Alarm1) that trigger the interrupts */ Cy_Rtc_SetInterruptMask(CY_RTC_INTR_ALARM1);
/* Wait for alarm to be set */
while(Cy_Rtc_SetAlarmDateAndTime(&alarm,CY_RTC_ALARM_1) != CY_RET_SUCCESS);
for(;;) { Cy_Rtc_GetDateAndTime(&Read_DateTime); } }
Code Listing 2 shows an example program of the RTC interrupt routine for alarm1.
Code Listing 2 Example Program of RTC Interrupt Routine for Alarm1
void Cy_Rtc_Alarm1Interrupt(void) { /* Clear any pending interrupts */ Cy_Rtc_ClearInterrupt(CY_RTC_INTR_ALARM1); }

2.1.4 Example Program to Configure RTC Function in Driver Part

Code Listing 3 to Code Listing 11 show an example program to configure the RTC in the driver part.
Code Listing 3 Example Program to Configure RTC Input Clock Source Set in Driver Part
void Cy_Rtc_clock_source(cy_en_rtc_clock_src_t clock_source) { BACKUP->unCTL.stcField.u2CLK_SEL = clock_source; }
(1) Set interrupt.
Select the source clock as ILO. See Code Listing 3.
Set the RTC initial time, date parameter. See Code Listing 4.
Clear interrupt. See Code Listing 8.
Set the interrupt mask. See Code Listing 9.
Set the ALARM1 time and date parameters. See Code Listing 10.
Interrupt routine for alarm1 function
(13) Clear the Interrupt flag for alarm1.
See Code Listing 8.
(2) Select the source clock as ILO
11 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 4 Example Program to Initialize RTC in Driver Part
cy_en_rtc_status_t Cy_Rtc_Init(cy_stc_rtc_config_t const *config) { cy_en_rtc_status_t retVal;
if(NULL != config) { retVal = Cy_Rtc_SetDateAndTime(config); } else { retVal = CY_RTC_INVALID_STATE; } return(retVal); }
Code Listing 5 Example Program to Set Date and Time Registers in Driver Part
cy_en_rtc_status_t Cy_Rtc_SetDateAndTime(cy_stc_rtc_config_t const *dateTime) { uint32_t tmpTime; uint32_t tmpDate; uint32_t tmpDaysInMonth; uint32_t interruptState;
cy_en_rtc_status_t retVal = CY_RTC_BAD_PARAM;
/* Check the input parameters valid ranges */ if((dateTime->month > 0u) && (dateTime->month <= CY_RTC_MONTHS_PER_YEAR) && (dateTime->year <= CY_RTC_MAX_YEAR)) { tmpDaysInMonth = Cy_Rtc_DaysInMonth(dateTime->month, (dateTime->year + CY_RTC_TWO_THOUSAND_YEARS));
/* Check if the date is in the valid range */ if((dateTime->date > 0u) && (dateTime->date <= tmpDaysInMonth)) { Cy_Rtc_ConstructTimeDate(dateTime, &tmpTime, &tmpDate);
/* The RTC AHB register can be updated only under condition that the
* Write bit is set and the RTC busy bit is cleared (CY_RTC_BUSY = 0). */
interruptState = Cy_SysLib_EnterCriticalSection(); retVal = Cy_Rtc_WriteEnable(CY_RTC_WRITE_ENABLED); if(retVal == CY_RTC_SUCCESS) { BACKUP->unRTC_TIME.u32Register = tmpTime; BACKUP->unRTC_DATE.u32Register = tmpDate;
/* Clear the RTC Write bit to finish RTC register update */ retVal = Cy_Rtc_WriteEnable(CY_RTC_WRITE_DISABLED); } Cy_SysLib_ExitCriticalSection(interruptState); } } return(retVal); }
This function sets the time, date parameters, WRITE bit. See Code Listing 5.
Set the initial time and date parameter in temporary structure. See Code Listing 6.
Set the WRITE bit for writing the time and date. See Code Listing 7.
(5) Set for BACKUP_RTC_TIME and BACKUP_RTC_DATE registers
Clear the WRITE bit. See Code Listing 7.
Check if configuration parameter values are valid
12 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 6 Example Program to Construct Time Date in Driver Part
static void Cy_Rtc_ConstructTimeDate(cy_stc_rtc_config_t const *timeDate, uint32_t *time, uint32_t *date) { uint32_t tmpTime; uint32_t tmpDate;
/* Prepare the RTC TIME value based on the structure obtained */ tmpTime = (_VAL2FLD(BACKUP_RTC_TIME_RTC_SEC, (timeDate->sec))); tmpTime |= (_VAL2FLD(BACKUP_RTC_TIME_RTC_MIN, (timeDate->min)));
/* Read the current hour mode to know how many hour bits to convert.
* In the 24-hour mode, the hour value is presented in [21:16] bits in the * Integer format. * In the 12-hour mode, the hour value is presented in [20:16] bits in the * Integer format and * bit [21] is present: 0 - AM; 1 - PM. */ if(timeDate->hrMode != CY_RTC_24_HOURS)
{ if(CY_RTC_AM != timeDate->amPm) { /* Set the PM bit */ tmpTime |= CY_RTC_BACKUP_RTC_TIME_RTC_PM; } else { /* Set the AM bit */ tmpTime &= ((uint32_t) ~CY_RTC_BACKUP_RTC_TIME_RTC_PM); } tmpTime |= BACKUP_RTC_TIME_CTRL_12HR_Msk; tmpTime |= (_VAL2FLD(BACKUP_RTC_TIME_RTC_HOUR, ((timeDate->hour) & ((uint32_t) ~CY_RTC_12HRS_PM_BIT)))); } else { tmpTime &= ((uint32_t) ~BACKUP_RTC_TIME_CTRL_12HR_Msk); tmpTime |= (_VAL2FLD(BACKUP_RTC_TIME_RTC_HOUR, (timeDate->hour))); } tmpTime |= (_VAL2FLD(BACKUP_RTC_TIME_RTC_DAY, (timeDate->dayOfWeek)));
/* Prepare the RTC Date value based on the structure obtained */
tmpDate = (_VAL2FLD(BACKUP_RTC_DATE_RTC_DATE,(timeDate->date)));
tmpDate |= (_VAL2FLD(BACKUP_RTC_DATE_RTC_MON, (timeDate->month))); tmpDate |= (_VAL2FLD(BACKUP_RTC_DATE_RTC_YEAR, (timeDate->year)));
/* Update the parameter values with prepared values */
*time = tmpTime;
*date = tmpDate; }
Set to Date parameters
(3) Set the initial time and date parameters in
temporary structure.
Set to Time parameters
13 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 7 Example Program to Write Enable in Driver Part
cy_en_rtc_status_t Cy_Rtc_WriteEnable(uint32_t writeEnable) { cy_en_rtc_status_t retVal = CY_RTC_INVALID_STATE;
if(writeEnable == CY_RTC_WRITE_ENABLED) { /* RTC Write bit set is possible only in condition that CY_RTC_BUSY bit = 0
* or RTC Read bit is not set */
if((CY_RTC_BUSY != Cy_Rtc_GetSyncStatus()) && (!_FLD2BOOL(BACKUP_RTC_RW_READ, BACKUP-> unRTC_RW.u32Register))) { BACKUP->unRTC_RW.u32Register |= BACKUP_RTC_RW_WRITE_Msk; retVal = CY_RTC_SUCCESS; } } else { /* Clearing Write Bit to complete write procedure */
BACKUP->unRTC_RW.u32Register &= ((uint32_t) ~BACKUP_RTC_RW_WRITE_Msk);
/* Delay to guarantee data write after clearing write bit */
Cy_SysLib_DelayUs(CY_RTC_DELAY_WRITE_US);
retVal = CY_RTC_SUCCESS; }
return(retVal); }
Code Listing 8 Example Program to Clear Interrupt in Driver Part
void Cy_Rtc_ClearInterrupt(uint32_t interruptMask) { BACKUP->unINTR.u32Register = interruptMask;
(void) BACKUP->unINTR.u32Register; }
Code Listing 9 Example Program to Set Interrupt mask in Driver Part
void Cy_Rtc_SetInterruptMask(uint32_t interruptMask) { BACKUP->unINTR_MASK.u32Register = interruptMask; }
(12) Clear the WRITE bit.
(4) Set the WRITE bit for writing the time and date.
(6) Clear the WRITE bit..
(10) Set the WRITE bit for writing
ALARM1 time and date.
(7) Clear interrupt
(8) Set interrupt mask
14 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 10 Example Program to Set Alarm Time and Date in Driver Part
cy_en_rtc_status_t Cy_Rtc_SetAlarmDateAndTime(cy_stc_rtc_alarm_t const *alarmDateTime, cy_en_rtc_alarm_t alarmIndex) { uint32_t tmpAlarmTime; uint32_t tmpAlarmDate; uint32_t tmpYear; uint32_t tmpDaysInMonth; uint32_t interruptState; cy_en_rtc_status_t retVal = CY_RTC_BAD_PARAM;
/* Read the current RTC time and date to validate the input parameters */ Cy_Rtc_SyncRegisters();
tmpYear = CY_RTC_TWO_THOUSAND_YEARS + (_FLD2VAL(BACKUP_RTC_DATE_RTC_YEAR, BACKUP->unRTC_DATE.u32Register));
/* Parameters validation */ if((alarmDateTime->month > 0u) && (alarmDateTime->month <= CY_RTC_MONTHS_PER_YEAR)) { tmpDaysInMonth = Cy_Rtc_DaysInMonth(alarmDateTime->month, tmpYear);
if((alarmDateTime->date > 0u) && (alarmDateTime->date <= tmpDaysInMonth)) { Cy_Rtc_ConstructAlarmTimeDate(alarmDateTime, &tmpAlarmTime, &tmpAlarmDate);
/* The RTC AHB register can be updated only under condition that the
* Write bit is set and the RTC busy bit is cleared (RTC_BUSY = 0). */
interruptState = Cy_SysLib_EnterCriticalSection(); retVal = Cy_Rtc_WriteEnable(CY_RTC_WRITE_ENABLED); if(CY_RTC_SUCCESS == retVal) {
/* Update the AHB RTC registers with formed values */
if(alarmIndex != CY_RTC_ALARM_2) { BACKUP->unALM1_TIME.u32Register = tmpAlarmTime; BACKUP->unALM1_DATE.u32Register = tmpAlarmDate; } else { BACKUP->unALM2_TIME.u32Register = tmpAlarmTime; BACKUP->unALM2_DATE.u32Register = tmpAlarmDate; }
/* Clear the RTC Write bit to finish RTC update */ retVal = Cy_Rtc_WriteEnable(CY_RTC_WRITE_DISABLED); } Cy_SysLib_ExitCriticalSection(interruptState); } } return(retVal); }
Set the ALARM1 time and date parameters in temporary structure. See Code Listing 11.
Set the WRITE bit for writing ALARM1 time and date. See Code Listing 7.
(11) Set the ALM1_TIME and
ALM1_DATE registers
Clear the WRITE bit. See Code Listing 7.
Check if configuration parameter values are valid
15 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 11 Example Program to Construct Alarm Time Date in Driver Part
static void Cy_Rtc_ConstructAlarmTimeDate(cy_stc_rtc_alarm_t const *alarmDateTime, uint32_t *alarmTime, uint32_t *alarmDate) { uint32_t tmpAlarmTime; uint32_t tmpAlarmDate; uint32_t hourValue;
/* Prepare the RTC ALARM value based on the structure obtained */
tmpAlarmTime = (_VAL2FLD(BACKUP_ALM1_TIME_ALM_SEC, (alarmDateTime->sec))); tmpAlarmTime |= (_VAL2FLD(BACKUP_ALM1_TIME_ALM_SEC_EN, alarmDateTime->sec_en)); tmpAlarmTime |= (_VAL2FLD(BACKUP_ALM1_TIME_ALM_MIN, (alarmDateTime->min))); tmpAlarmTime |= (_VAL2FLD(BACKUP_ALM1_TIME_ALM_MIN_EN, alarmDateTime->min_en));
/* Read the current hour mode to know how many hour bits to convert.
* In the 24-hour mode, the hour value is presented in [21:16] bits in the * Integer format. * In the 12-hour mode, the hour value is presented in [20:16] bits in the * Integer format and bit [21] is present: 0 - AM; 1 - PM */
Cy_Rtc_SyncRegisters(); if(CY_RTC_24_HOURS != Cy_Rtc_GetHoursFormat()) { /* Convert the hour from the 24-hour mode into the 12-hour mode */
if(alarmDateTime->hour >= CY_RTC_HOURS_PER_HALF_DAY)
{ /* The current hour is more than 12 in the 24-hour mode. Set the PM
* bit and converting hour: hour = hour - 12 */ hourValue = (uint32_t) alarmDateTime->hour - CY_RTC_HOURS_PER_HALF_DAY;
hourValue = ((0u != hourValue) ? hourValue : CY_RTC_HOURS_PER_HALF_DAY); tmpAlarmTime |= CY_RTC_BACKUP_RTC_TIME_RTC_PM | (_VAL2FLD(BACKUP_ALM1_TIME_ALM_HOUR, (hourValue))); } else if(alarmDateTime->hour < 1u) { /* The current hour in the 24-hour mode is 0 which is equal to 12:00 AM */ tmpAlarmTime = (tmpAlarmTime & ((uint32_t) ~CY_RTC_BACKUP_RTC_TIME_RTC_PM)) | (_VAL2FLD(BACKUP_ALM1_TIME_ALM_HOUR, CY_RTC_HOURS_PER_HALF_DAY)); } else { /* The current hour is less than 12. Set the AM bit */ tmpAlarmTime = (tmpAlarmTime & ((uint32_t) ~CY_RTC_BACKUP_RTC_TIME_RTC_PM)) | (_VAL2FLD(BACKUP_ALM1_TIME_ALM_HOUR, (alarmDateTime->hour))); } tmpAlarmTime |= BACKUP_RTC_TIME_CTRL_12HR_Msk; } else { tmpAlarmTime |= (_VAL2FLD(BACKUP_ALM1_TIME_ALM_HOUR, (alarmDateTime->hour))); tmpAlarmTime &= ((uint32_t) ~BACKUP_RTC_TIME_CTRL_12HR_Msk); } tmpAlarmTime |= (_VAL2FLD(BACKUP_ALM1_TIME_ALM_HOUR_EN, alarmDateTime->hour_en)); tmpAlarmTime |= (_VAL2FLD(BACKUP_ALM1_TIME_ALM_DAY, (alarmDateTime->dayOfWeek))); tmpAlarmTime |= (_VAL2FLD(BACKUP_ALM1_TIME_ALM_DAY_EN, alarmDateTime->dayOfWeek_en));
/* Prepare the RTC ALARM DATE value based on the obtained structure */
tmpAlarmDate = (_VAL2FLD(BACKUP_ALM1_DATE_ALM_DATE, (alarmDateTime->date))); tmpAlarmDate |= (_VAL2FLD(BACKUP_ALM1_DATE_ALM_DATE_EN, alarmDateTime->date_en)); tmpAlarmDate |= (_VAL2FLD(BACKUP_ALM1_DATE_ALM_MON, (alarmDateTime->month))); tmpAlarmDate |= (_VAL2FLD(BACKUP_ALM1_DATE_ALM_MON_EN, alarmDateTime->month_en)); tmpAlarmDate |= (_VAL2FLD(BACKUP_ALM1_DATE_ALM_EN, alarmDateTime->alm_en));
/* Update the parameter values with prepared values */
*alarmTime = tmpAlarmTime; *alarmDate = tmpAlarmDate;
}
Set to ALARM Time parameters
Set ALARM date parameters
(9) Set the ALARM1 time and date parameter in temporary structure.
16 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview

2.2 Reading TIME and DATE

To display the current time on the clock screen of a vehicle, the CPU reads the current time for the RTC field registers.
The RTC function of the Traveo II device has a READ bit in the BACKUP_RTC_RW register that will be used to copy the current RTC field values in the RTC registers to the RTC field in the user registers in real time. The RTC field values in the user registers are frozen and are not updated even if the RTC field values in the RTC registers are updated. Then, the user firmware can copy the frozen RTC values to a user buffer, which are local variables assigned in RAM.
Figure 3 describes the use case of reading the current time. The example uses the current time as April 30th
11:59:59 PM (11 hours 59 minutes 59 seconds). First, set the READ bit in the BACKUP_RTC_RW register to ‘1’. Immediately, the hardware copies the current RTC field data in the RTC register to the RTC field in the user register, then the user firmware clears the READ bit to ‘0’. After that you can read the user register for the current date and time.
This section explains how to read the RTC value based on a use case using the SDL. The code snippets in this application note are part of SDL. See Other References for the SDL.
Traveo II Device
CPU
RTC
RAM
AHB-Lite Bus
RTC Register
RTC Field
BACKUP_RTC_DATE
BACKUP_RTC_TIME
User Buffer MON DATE HOUR MIN
11
/ :
59:/4 30
Timing at BACKUP_RTC_RW.READ = '1' : BACKUP_RTC_DATE.RTC_MON = 4
BACKUP_RTC_DATE.RTC_DATE = 30
BACKUP_RTC_TIME.RTC_HOUR[20] = 1 BACKUP_RTC_TIME.RTC_HOUR[19:16] = 11 BACKUP_RTC_TIME.RTC_MIN = 59 BACKUP_RTC_TIME.RTC_SEC = 59
Read the correct time from registers at anytime.
User Register
RTC Field
BACKUP_RTC_DATE
BACKUP_RTC_TIME
Copied and Frozen at this timing.
Figure 3 Correct Time is Read with READ Bit

2.2.1 Use Case

This section explains an example to read RTC value in the following use case. In this example, the following items are read regularly. Therefore, these have no fixed values.
Use case: Reading RTC values
Read Data: Read_DateTime
Figure 4 shows an example flow to read the RTC value.
17 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Start
Check WRITE Bit Status
(1)
(2)
(3)
(4)
(5)
(6)
Set READ Bit to Read Time and
Date
Wait for Time Required for Read
Clear READ Bit
Read Time and Date
Parameters
End
Check RTC Busy Status
Figure 4 Example Flow to Read RTC Value

2.2.2 Reading the RTC Values

The following example describes the operation of reading the RTC values:
1. Check the busy status; wait until BACKUP_STATUS.RTC_BUSY = ‘0’ to ensure safe design
1
.
2. Check the write status; wait until BACKUP_RTC_RW.WRITE = ‘0’ to ensure safe design
2
.
3. Set the READ bit to prepare for the read operation of the RTC values:
Write BACKUP_RTC_RW.READ = ‘1’ (Begin the Read operation). Then, the current RTC field values in the RTC registers are copied to the RTC field in the user registers, and then the hardware freezes the values.
4. Wait for a read operation time (183 us).
5. Clear the READ bit:
Write BACKUP_RTC_RW.READ = ‘0’ (End the Read operation).
6. Read the time and date parameters from the user register:
Get time parameter = BACKUP_RTC_TIME Get date parameter = BACKUP_RTC_DATE
1
The subsequent reading operation cannot be executed until the previous operation is completed.
2
The subsequent reading operation cannot be executed when the WRITE bit is set.
18 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview

2.2.3 Items Read for RTC Value

Table 3 lists the parameters that store the RTC data readings. These items are the same as the initialization
items listed in Table 1 and Table 2.
Table 3 List of Read RTC Values
Parameters
Description
Read_DateTime.sec
Stored second value (Calendar seconds, 0-59)
Read_DateTime.min
Stored minute value (Calendar minutes, 0-59)
Read_DateTime.hour
Stored hour value (Calendar hours, value depending on 12/24HR mode)
Read_DateTime.hrMode
Stored hour HR mode value (12/24HR mode, 0 or 1)
Read_DateTime.dayOfWeek
Stored day value (Calendar Day of the week, 1-7) You can define the values, but it is recommended to set 1=Monday .
Read_DateTime.date
Stored day of the month value (Calendar Day of the Month, 1-31) Automatic Leap Year Correction
Read_DateTime.month
Stored month value (Calendar Month, 1-12)
Read_DateTime.year
Stored year value (Calendar year, 0-99)
Code Listing 12 shows an example program of the reading RTC value. In the example, the program code of the
initialization part of the main routine was omitted.
Code Listing 12 Example Program to Read RTC Value
int main(void) { SystemInit();
cy_stc_rtc_config_t Read_DateTime;
__enable_irq(); /* Enable global interrupts. */
·
·
for(;;) { Cy_Rtc_GetDateAndTime(&Read_DateTime); } }
Read the time and date. See Code Listing 13.
Configuration structure for reading RTC values
The initialization part is omitted.
19 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Code Listing 13 to Code Listing 15 show an example program to read RTC value in the driver part.
Code Listing 13 Example Program to Read RTC Time and Date Value in Driver Part
void Cy_Rtc_GetDateAndTime(cy_stc_rtc_config_t* dateTime) { uint32_t tmpTime; uint32_t tmpDate;
/* Read the current RTC time and date to validate the input parameters */ Cy_Rtc_SyncRegisters();
/* Write the AHB RTC registers date and time into the local variables and
* updating the dateTime structure elements */
tmpTime = BACKUP->unRTC_TIME.u32Register; tmpDate = BACKUP->unRTC_DATE.u32Register;
dateTime->sec = (_FLD2VAL(BACKUP_RTC_TIME_RTC_SEC, tmpTime)); dateTime->min = (_FLD2VAL(BACKUP_RTC_TIME_RTC_MIN, tmpTime)); dateTime->hrMode = (_FLD2VAL(BACKUP_RTC_TIME_CTRL_12HR, tmpTime));
/* Read the current hour mode to know how many hour bits should be converted * In the 24-hour mode, the hour value is presented in [21:16] bits in the * Integer format. * In the 12-hour mode the hour value is presented in [20:16] bits in * the Integer format and bit [21] is present: 0 - AM; 1 - PM. */
if(dateTime->hrMode != CY_RTC_24_HOURS) { dateTime->hour = ((tmpTime & CY_RTC_BACKUP_RTC_TIME_RTC_12HOUR) >> BACKUP_RTC_TIME_RTC_HOUR_Pos);
dateTime->amPm = ((0u != (tmpTime & CY_RTC_BACKUP_RTC_TIME_RTC_PM)) ? CY_RTC_PM : CY_RTC_AM); } else { dateTime->hour = (_FLD2VAL(BACKUP_RTC_TIME_RTC_HOUR, tmpTime)); } dateTime->dayOfWeek =(_FLD2VAL(BACKUP_RTC_TIME_RTC_DAY, tmpTime)); dateTime->date = (_FLD2VAL(BACKUP_RTC_DATE_RTC_DATE, tmpDate)); dateTime->month = (_FLD2VAL(BACKUP_RTC_DATE_RTC_MON, tmpDate)); dateTime->year = (_FLD2VAL(BACKUP_RTC_DATE_RTC_YEAR, tmpDate)); }
Code Listing 14 Example Program to RTC Sync Register in Driver Part
void Cy_Rtc_SyncRegisters(void) { uint32_t interruptState;
interruptState = Cy_SysLib_EnterCriticalSection();
/* RTC Write is possible only in the condition that CY_RTC_BUSY bit = 0
* or RTC Write bit is not set. */
if((CY_RTC_BUSY != Cy_Rtc_GetSyncStatus()) && (!_FLD2BOOL(BACKUP_RTC_RW_WRITE, BACKUP-> unRTC_RW.u32Register))) { /* Setting RTC Read bit */ BACKUP->unRTC_RW.u32Register = BACKUP_RTC_RW_READ_Msk;
/* Delay to guarantee RTC data reading */ Cy_SysLib_DelayUs(CY_RTC_DELAY_WHILE_READING_US);
/* Clearing RTC Read bit */ BACKUP->unRTC_RW.u32Register = 0u; } Cy_SysLib_ExitCriticalSection(interruptState); }
Check the status for reading and setting the READ bit. See Code Listing 14.
(6) Read the time and date parameters
from user register
Check RTC busy status. See Code Listing 15.
(2) Check WRITE bit status
(3) Set the READ bit for read the time and date
(4) Wait for a time required for Read
(5) Clear the READ bit
20 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 15 Example Program to Get Sync Status in Driver Part
uint32_t Cy_Rtc_GetSyncStatus(void) { return((_FLD2BOOL(BACKUP_STATUS_RTC_BUSY, BACKUP->unSTATUS.u32Register)) ? CY_RTC_BUSY : CY_RTC_AVAILABLE); }

2.3 Updating TIME and DATE

The RTC fields can be updated independently. Each RTC field in the user register has an independent update flag. These are internal flags which are not accessed by a user firmware. These flags are set by writing values to the RTC fields in the user register. The writing instruction (BACKUP_RTC_RW.WRITE = ‘0’) writes to only those fields where the update flag is set.
This section explains how to update the RTC value based on a use case using the Sample Driver Library (SDL) provided by Cypress. The code snippets in this application note are part of SDL. See Other References for the SDL.

2.3.1 Use Case

This use case shows how to adjust daylight saving time (DST). For adjusting DST, only the RTC_HOUR bit field needs to be updated. The other fields are not unchanged.
Use case:
Set the RTC initial value
2018 year, June, 19 day, Tuesday, 2 hour (12HR mode), 43 minute, 0 second
Update the calendar hour in the RTC value from '2' to '3'
Figure 5 shows an example flow to update RTC value.
Start
Check READ Bit Status
(1)
(2)
(3)
(4)
(5)
Set WRITE Bit to WRite RTC
Value
Write the Time to the RTC Field
in User Register
Clear WRITE Bit
End
Check RTC Busy Status
Set RTC Initial Value
(6)
Figure 5 Example Flow to Update RTC Value
(1) Check RTC busy status
21 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview

2.3.2 Updating the RTC Values (For Example, Adjusting DST)

1. Set the RTC initial value. For the initial setting method, see Initializing the RTC Function.
2. Check the busy status; wait until BACKUP_STATUS.RTC_BUSY = ‘0’.
3. Check the read status; if BACKUP_RTC_RW.READ is not ‘0’, clear the READ bit (BACKUP_RTC_RW.READ = ‘0’).
Then, wait until BACKUP_RTC_RW.READ = ‘0’.
4. Set the WRITE bit to prepare for the write operation of the RTC values:
Write BACKUP_RTC_RW.WRITE = ‘1’ (Begin the Write operation)
5. Write the time to the RTC field in the user register:
Write BACKUP_RTC_TIME. RTC_HOUR = ‘3’ For adjusting DST, ‘3’ is written to the RTC_HOUR bit field instead of ‘2’ to adjust the summer time at 2 AM on the first Sunday of April in the United States. The other RTC fields, BACKUP_RTC_TIME.RTC_SEC, RTC_MIN, 12HR, DAY, DATE, MON, and YEAR, are left unchanged.
6. Clear the WRITE bit:
Write BACKUP_RTC_RW.WRITE = ‘0’ (End the Write operation)
Table 3 lists the RTC initial parameters of the configuration part of SDL. After initializing with the values in Table 3, update the RTC value.
Table 4 List of Initial RTC Value Parameters
Parameters
Description
Value
RTC_config.sec
Calendar seconds, 0-59
RTC_INITIAL_DATE_SEC = 0ul
RTC_config.min
Calendar minutes, 0-59
RTC_INITIAL_DATE_MIN = 43ul
RTC_config.hour
Calendar hours, value depending on 12/24HR mode
RTC_INITIAL_DATE_HOUR = 2ul
RTC_config.hrMode
Select 12/24HR mode: 1=12HR, 0=24HR CY_RTC_12_HOURS = 1ul, CY_RTC_24_HOURS = 0ul
RTC_INITIAL_DATE_HOUR_FORMAT = CY_RTC_12_HOURS
RTC_config.dayOfWeek
Calendar Day of the week, 1-7 It is up to the user to define the meaning
of the values, but 1=Monday is recommended
RTC_INITIAL_DATE_DOW = 2ul
RTC_config.date
Calendar Day of the Month, 1-31 Automatic Leap Year Correction
RTC_INITIAL_DATE_DOM = 19ul
RTC_config.month
Calendar Month, 1-12
RTC_INITIAL_DATE_MONTH = 6ul
RTC_config.year
Calendar year, 0-99
RTC_INITIAL_DATE_YEAR = 18ul
Table 5 lists the parameter and Table 6 lists the functions of the configuration part of SDL with updated RTC
values.
Table 5 List of Updated RTC Value Parameter
Parameter
Description
Value
RTC_UPDATE_HOUR
Calendar hours, value depending on 12/24HR mode
3ul
22 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Table 6 List of Updated RTC Value Function
Functions
Description
Value
Cy_Rtc_IsReadBitSet (void)
Returns READ bit status. 1: READ bit is set. 0: READ bit is cleared
-
Cy_Rtc_ClearReadBit (void)
Clears READ bit.
-
Cy_Rtc_SetHourBit (uint8_t hour)
Only sets the RTC hour value
RTC_UPDATE_HOUR = 3ul
Code Listing 16 shows an example program of the updated RTC value.
The following description will help you understand the register notation of the driver part of SDL:
BACKUP->unRTC_TIME register is the BACKUP_RTC_TIME register mentioned in the Register TRM. Other
registers are also described in the same manner.
Code Listing 16 Example Program to Update RTC Value
/* RTC Hour value for update */
#define RTC_UPDATE_HOUR (3ul) /**< Calendar hours for update */
/* RTC configuration */
cy_stc_rtc_config_t const RTC_config = { /* Initiate time and date */ .sec = RTC_INITIAL_DATE_SEC, .min = RTC_INITIAL_DATE_MIN, .hour = RTC_INITIAL_DATE_HOUR, .hrMode = RTC_INITIAL_DATE_HOUR_FORMAT, .dayOfWeek = RTC_INITIAL_DATE_DOW, .date = RTC_INITIAL_DATE_DOM, .month = RTC_INITIAL_DATE_MONTH, .year = RTC_INITIAL_DATE_YEAR, };
int main(void) { cy_en_rtc_status_t retVal; uint8_t retStatus; uint32_t interruptState;
SystemInit();
__enable_irq(); /* Enable global interrupts. */
/* Set the WCO as the clock source to the RTC block */ retStatus = Cy_SysClk_WcoEnable(100ul); if(retStatus == CY_SYSCLK_SUCCESS) { Cy_Rtc_clock_source(CY_RTC_CLK_SRC_WCO); }
/* Wait for initial setting */ while(Cy_Rtc_Init(&RTC_config) != CY_RET_SUCCESS);
/* Check for RTC busy status */ while(Cy_Rtc_GetSyncStatus()==CY_RTC_BUSY);
/* Check for RTC read bit clear */ if(Cy_Rtc_IsReadBitSet()==1) { Cy_Rtc_ClearReadBit(); } /* Check for read bit status */ while(Cy_Rtc_IsReadBitSet()==1);
(1) Set the RTC initial value. The initialization part is omitted. See Code Listing 4.
Check RTC busy status. See Code Listing 17 .
Check READ bit status. See Code Listing 1 8 and
Code Listing 19.
Set the WCO clock source to RTC. See Code Listing 29.
Configure initial time and date parameters. See Table 4.
RTC Hour value for update. See Table 5.
23 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 16 Example Program to Update RTC Value
/* Set to RTC write bit */ interruptState = Cy_SysLib_EnterCriticalSection(); retVal = Cy_Rtc_WriteEnable(CY_RTC_WRITE_ENABLED); if(retVal == CY_RTC_SUCCESS) { /* Set hour value for updating */ Cy_Rtc_SetHourBit(RTC_UPDATE_HOUR);
/* Clear the RTC Write bit */ Cy_Rtc_WriteEnable(CY_RTC_WRITE_DISABLED); } Cy_SysLib_ExitCriticalSection(interruptState);
for(;;) {
} }

2.3.3 Example Program to Update RTC Values in Driver Part

Code Listing 17 to Code Listing 20 shows an example program to update the RTC values in the driver part.
Code Listing 17 Example Program to Get Sync Status in Driver Part
uint32_t Cy_Rtc_GetSyncStatus(void) { return((_FLD2BOOL(BACKUP_STATUS_RTC_BUSY, BACKUP->unSTATUS.u32Register)) ? CY_RTC_BUSY : CY_RTC_AVAILABLE); }
Code Listing 18 Example Program to Check the READ bit Status in Driver Part
bool Cy_Rtc_IsReadBitSet(void) { if(BACKUP->unRTC_RW.stcField.u1READ == 0ul) { return false; } else { return true; }
}
Code Listing 19 Example Program to Clear the READ bit in Driver Part
cy_en_rtc_status_t Cy_Rtc_ClearReadBit(void) { BACKUP->unRTC_RW.stcField.u1READ = 0ul;
return(CY_RTC_SUCCESS); }
Set the WRITE bit to write the RTC value. See Code Listing 7.
Write the time to the RTC field in the user register. See Code Listing 20.
Clear the WRITE bit. See Code Listing 7. (2) Check RTC busy status
(3) Check READ bit status.
This function clears the READ bit to 0.
24 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 20 Example Program to Set the RTC hour value in Driver Part
cy_en_rtc_status_t Cy_Rtc_SetHourBit(uint8_t hour) { BACKUP->unRTC_TIME.stcField.u5RTC_HOUR = hour; return CY_RTC_SUCCESS;
}

2.4 Calibrating WCO

Note: Calibration of WCO is possible only on the device having the RTC_PIN.
Even if the WCO uses a crystal oscillator, it is not immune to frequency errors. The RTC values may not correspond to the standard time in your region because of such errors. In such cases, the user has the capability to calibrate the WCO and improve the accuracy of the real-time clock.
This section explains how to calibrate the WCO based on a use case using the Sample Driver Library (SDL) provided by Cypress. The code snippets in this application note are part of SDL. See Other References for the SDL.

2.4.1 Use Case

This use case shows how to output the calibration waveform, set the calibration value, and confirm the calibration.
Use case:
Output the 512-Hz calibration waveform to the RTC_CAL pin.
Set the calibration value in the register based on 27.125 ppm slow down calibration waveform
Confirm the calibration waveform in the 1-Hz output.
This use case has the following three steps:
1. Routing the WCO waveform to the RTC_CAL pin and capturing the waveform
2. Measuring the difference (frequency) between the ideal waveform and the actual WCO output, and setting a
calibration value
3. Confirming the accuracy of the WCO frequency by re-measuring

2.4.2 Capturing the WCO Waveform

The WCO waveform can be captured in an oscilloscope by routing it to the RTC_CAL pin of the device. This can be achieved by setting the CAL_OUT bit. A 512-Hz clock waveform, derived from the WCO, will be output on the RTC_CAL pin. You must measure the deviation of this output from an ideal 512-Hz clock, and convert the deviation to a ppm value. Then, you can calculate the calibration settings to be used to correct the WCO frequency error. Before executing this operation, the RTC function must be run normally with the configuration specified in Table 3.
Figure 6 shows an example flow to calibrate WCO waveform output.
(5) Write the time to the RTC field in the
user register.
25 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Start
Check READ Bit Status
(1)
(2)
(3)
(4)
(5)
Set WRITE Bit to Update Output
of Calibration Waveform
Enable Calibration Waveform
Output
Clear WRITE Bit
End
Check RTC Busy Status
Set WCO Clock Source to RTC
(6)
Configure the RTC_CAL Pin
(8)
Set Waveform Frequency for
512 Hz
(7)
Figure 6 Example Flow to Calibrate WCO Waveform Output
The following steps show how to output the WCO waveform:
1. Set the WCO clock source to the RTC
2. Configure the RTC_CAL pin; see the I/O System chapter in the Architecture TRM.
3. Check the busy status; wait until BACKUP_STATUS.RTC_BUSY = ‘0’ to ensure safe design.
1
4. Check the read status; if BACKUP_RTC_RW.READ is not ‘0’, clear the READ bit (BACKUP_RTC_RW.READ = ‘0’).
Then, wait until BACKUP_RTC_RW.READ = ‘0’ to ensure safe design.2
5. Set the WRITE bit to update the output of the calibration waveform:
Write BACKUP_RTC_RW.WRITE = ‘1’ (Begin the Write operation)
6. Set waveform frequency for 512 Hz:
Write BACKUP_CAL_CTL.CAL_SEL = ‘0’
7. Enable the calibration waveform:
Write BACKUP_CAL_CTL.CAL_OUT = ‘1’ (Calibration waveform output). Then, the WCO waveform is output on the RTC_CAL pin.
8. Clear the WRITE bit:
Write BACKUP_RTC_RW.WRITE = ‘0’ (End the Write operation).
Table 7 lists the parameters of the configuration part in SDL to RTC_CAL pin output in GPIO.
For GPIO setting, see the I/O System chapter in the Architecture TRM.
1
The subsequent calibration operation cannot be executed while executing the previous operation.
2
The subsequent writing operation cannot be executed while the READ bit is set.
26 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Table 7 List of RTC_CAL Pin Output in GPIO
Parameters
Description
Value
user_led_port_pin_cfg.outVal
Selects pin output state. 0: Output state not affected, 1: Output state
set to ‘0’
0ul
user_led_port_pin_cfg.driveMode
Selects GPIO drive mode for IO pin. 0: Analog High Impedance 1: Reserved and should not be used 2: Resistive pull-up 3: Resistive pull-down 4: Open drain, drives LOW 5: Open drain, drives HIGH 6: Strong drive 7: Resistive pull-up/down 8: Digital High-Z. Input buffer ON. 9: Resistive Pull-Up. Input buffer ON. 10: Resistive Pull-Down. Input buffer ON. 11: Open Drain, Drives LOW. Input buffer ON. 12: Open Drain, Drives HIGH. Input buffer ON. 13: Strong Drive. Input buffer ON. 14: Resistive Pull-Up/Down. Input buffer ON.
CY_GPIO_DM_STRON G_IN_OFF =6ul
user_led_port_pin_cfg.hsiom
Sets connection for RTC_CAL pin route.
P1_2_SRSS_CAL_WAV E
user_led_port_pin_cfg.intEdge
Sets the edge which will trigger an IRQ for IO pin.
0: Disabled, 1: Rising edge, 2: Falling edge, 3: Both
0ul
user_led_port_pin_cfg.intMask
Masks edge interrupt on IO pin. 0: Pin interrupt forwarding disabled 1: Pin interrupt forwarding enabled
0ul
user_led_port_pin_cfg.vtrip
Selects the IO pin input buffer mode. 0: CMOS, 1: TTL
0ul
user_led_port_pin_cfg.slewRate
Selects slew rate for IO pin. 0: Fast slew rate, 1: Slow slew rate
0ul
user_led_port_pin_cfg.driveSel
Sets the GPIO drive strength for IO pin. 0: Full drive strength 1: Full drive strength 2: 1/2 drive strength 3: 1/4 drive strength
0ul
Table 8 lists the parameters and Table 9 lists the function of the configuration part in SDL to RTC calibration
waveform output.
27 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Table 8 List of RTC Calibration Waveform Output Parameters
Parameters
Description
Value
CALIB_VALUE
Calibration value for absolute frequency. Each step causes 128 ticks to be added or removed each hour.
0ul
CY_EN_RTC_CALIB_SIGN_NEGATIVE
0: Negative sign: Removes pulses (it takes more clock ticks to count one second)
1: Positive sign: Adds pulses (it takes less clock ticks to count one second)
0
CY_EN_RTC_CAL_SEL_CAL512
Select calibration wave output signal 0: 512-Hz wave, not affected by calibration setting. 1: reserved 2: 2-Hz wave, includes the effect of the calibration setting. 3: 1-Hz wave, includes the effect of the calibration setting.
0
Table 9 List of RTC Calibration Waveform Output Functions
Function
Description
Value
Cy_Rtc_CalibrationControlEnable (uint8_t calib_val,
cy_en_rtc_calib_sign_t calib_sign, cy_en_rtc_cal_sel_t cal_sel)
Set calibration control register and enable to calibration wave form output
calib_val:. Calibration value for absolute frequency.
calib_sign: Calibration sign
cal_sel: Select calibration wave output signal
CALIB_VALUE = 0ul, CY_EN_RTC_CALIB_SIGN_NEGATIVE=0, CY_EN_RTC_CAL_SEL_CAL512 = 0
Code Listing 18 shows an example program of the RTC calibration waveform output.
The following description will help you understand the register notation of the driver part of SDL:
BACKUP->unCAL_CTL register is the BACKUP_CAL_CTL register mentioned in the Register TRM. Other
registers are also described in the same manner.
The RTC_CAL pin configuration shows the case of the CYT4DN series. These RTC_CAL pin settings are the same for example Code Listing 21, Code Listing 28, and Code Listing 34.
Code Listing 21 Example Program of RTC Calibration Waveform Output
/* Configure the RTC_CAL pin definition (P1_2)pin */
#define RTC_CAL_PIN P1_2_SRSS_CAL_WAVE #define USER_PORT GPIO_PRT1 #define USER_PIN 2
/* Setting value for calibration definition */
#define CALIB_VALUE 0ul
/* RTC configuration */
cy_stc_rtc_config_t const RTC_config =
Definition for RTC_CAL.
Definition for calibration value
28 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 21 Example Program of RTC Calibration Waveform Output
{ /* Initiate time and date */ .sec = RTC_INITIAL_DATE_SEC, .min = RTC_INITIAL_DATE_MIN, .hour = RTC_INITIAL_DATE_HOUR, .hrMode = RTC_INITIAL_DATE_HOUR_FORMAT, .dayOfWeek = RTC_INITIAL_DATE_DOW, .date = RTC_INITIAL_DATE_DOM, .month = RTC_INITIAL_DATE_MONTH, .year = RTC_INITIAL_DATE_YEAR, };
/* RTC_CAL pin configuration */
cy_stc_gpio_pin_config_t user_led_port_pin_cfg = { .outVal = 0ul, .driveMode = CY_GPIO_DM_STRONG_IN_OFF, .hsiom = RTC_CAL_PIN, .intEdge = 0ul, .intMask = 0ul, .vtrip = 0ul, .slewRate = 0ul, .driveSel = 0ul,
};
int main(void) { cy_en_rtc_status_t retVal; uint8_t retStatus; uint32_t interruptState;
SystemInit();
__enable_irq(); /* Enable global interrupts. */
/* Set the WCO as the clock source to the RTC block */ retStatus = Cy_SysClk_WcoEnable(100ul); if(retStatus == CY_SYSCLK_SUCCESS) { Cy_Rtc_clock_source(CY_RTC_CLK_SRC_WCO); }
/* Configure the RTC_CAL pin */ Cy_GPIO_Pin_Init(USER_PORT, USER_PIN, &user_led_port_pin_cfg);
/* Wait for initial setting */ while(Cy_Rtc_Init(&RTC_config) != CY_RET_SUCCESS);
/* Check for RTC busy status */ while(Cy_Rtc_GetSyncStatus()==CY_RTC_BUSY);
/* Check for RTC read bit clear */ if(Cy_Rtc_IsReadBitSet()==1) { Cy_Rtc_ClearReadBit(); }
/* Check for read bit status */ while(Cy_Rtc_IsReadBitSet()==1);
/* Set to RTC write bit */ interruptState = Cy_SysLib_EnterCriticalSection(); retVal = Cy_Rtc_WriteEnable(CY_RTC_WRITE_ENABLED); if(retVal == CY_RTC_SUCCESS) { /* Calibration waveform output enable */ Cy_Rtc_CalibrationControlEnable(CALIB_VALUE, CY_EN_RTC_CALIB_SIGN_NEGATIVE, CY_EN_RTC_CAL_SEL_CAL512); /* Clear the RTC Write bit */ Cy_Rtc_WriteEnable(CY_RTC_WRITE_DISABLED); } Cy_SysLib_ExitCriticalSection(interruptState);
(2) Configure the RTC_CAL pin
Set the RTC initial value. The initialization part is omitted. See Code Listing 4.
Check RTC busy status. See Code Listing 23.
Check READ bit status. See Code Listing 24, Code Listing 25 .
Set the WRITE bit for write the CAL_OUT field. See Code Listing 26.
Clear the WRITE bit. See Code Listing 26 .
Configuration for RTC_CAL in the GPIO. See Table 7.
Set the WCO clock source to the RTC. See Code Listing 22.
Set waveform frequency and enable the calibration waveform output. See Code Listing 27.
Configure initial time and date parameters.See Table 4.
29 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 21 Example Program of RTC Calibration Waveform Output
for(;;) {
} }

2.4.3 Example Program to Capture WCO Waveform in Driver Part

Code Listing 22 to Code Listing 27 show an example program to capture the WCO waveform in the driver part.
Code Listing 22 Example Program to RTC Input Clock Source Set in Driver Part
void Cy_Rtc_clock_source(cy_en_rtc_clock_src_t clock_source) { BACKUP->unCTL.stcField.u2CLK_SEL = clock_source; }
Code Listing 23 Example Program to Get Sync Status in Driver Part
uint32_t Cy_Rtc_GetSyncStatus(void) { return((_FLD2BOOL(BACKUP_STATUS_RTC_BUSY, BACKUP->unSTATUS.u32Register)) ? CY_RTC_BUSY : CY_RTC_AVAILABLE); }
Code Listing 24 Example Program to Check the READ Bit Status in Driver Part
bool Cy_Rtc_IsReadBitSet(void) { if(BACKUP->unRTC_RW.stcField.u1READ == 0ul) { return false; } else { return true; } }
Code Listing 25 Example Program to Clear the READ bit in Driver Part
cy_en_rtc_status_t Cy_Rtc_ClearReadBit(void) { BACKUP->unRTC_RW.stcField.u1READ = 0ul;
return(CY_RTC_SUCCESS); }
Code Listing 26 Example Program to Write Enable in Driver Part
cy_en_rtc_status_t Cy_Rtc_WriteEnable(uint32_t writeEnable) { cy_en_rtc_status_t retVal = CY_RTC_INVALID_STATE;
if(writeEnable == CY_RTC_WRITE_ENABLED) { /* RTC Write bit set is possible only in condition that CY_RTC_BUSY bit = 0
* or RTC Read bit is not set */
if((CY_RTC_BUSY != Cy_Rtc_GetSyncStatus()) && (!_FLD2BOOL(BACKUP_RTC_RW_READ, BACKUP-> unRTC_RW.u32Register)))
(1) Set the WCO clock source to the RTC. (3) Check RTC busy status.
(4) Check READ bit status.
This function clears the READ bit to 0.
30 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 24 Example Program to Check the READ Bit Status in Driver Part
{ BACKUP->unRTC_RW.u32Register |= BACKUP_RTC_RW_WRITE_Msk; retVal = CY_RTC_SUCCESS; } } else { /* Clearing Write Bit to complete write procedure */
BACKUP->unRTC_RW.u32Register &= ((uint32_t) ~BACKUP_RTC_RW_WRITE_Msk);
/* Delay to guarantee data write after clearing write bit */
Cy_SysLib_DelayUs(CY_RTC_DELAY_WRITE_US);
retVal = CY_RTC_SUCCESS; }
return(retVal); }
Code Listing 27 Example Program to Set the Calibration Control Enable in Driver Part
cy_en_rtc_status_t Cy_Rtc_CalibrationControlEnable(uint8_t calib_val, cy_en_rtc_calib_sign_t calib_sign, cy_en_rtc_cal_sel_t cal_sel) { if(BACKUP->unRTC_RW.stcField.u1WRITE == 0) { // Writes are ignored unless Write bit is set return CY_RTC_INVALID_STATE; }
un_BACKUP_CAL_CTL_t tmpBackupCalCtl = {0ul}; tmpBackupCalCtl.stcField.u6CALIB_VAL = calib_val; tmpBackupCalCtl.stcField.u1CALIB_SIGN = (uint32_t)calib_sign; tmpBackupCalCtl.stcField.u2CAL_SEL = (uint32_t)cal_sel; tmpBackupCalCtl.stcField.u1CAL_OUT = 1ul; // Output enable for wave signal for calibration and allow CALIB_VAL to be written. BACKUP->unCAL_CTL.u32Register = tmpBackupCalCtl.u32Register;
return CY_RTC_SUCCESS; }

2.4.4 Measuring the Difference Between the WCO and an Ideal Waveform

After outputting the WCO waveform (512 Hz) on to the external pin of RTC_CAL, measure the difference between the calibration waveform and the ideal waveform such as an atomic clock or calibrated lab equipment. Measure the difference using an external calibrated lab equipment, and not using the same Traveo II device. This external equipment calculates the ppm value based on the difference between the two clock signals. The example of measuring the calibration waveform is shown in Figure 7.
Ideal Waveform
Difference
RTC_CAL Waveform
Output from RTC_CAL Pin
WCO
Traveo II
Device
Figure 7 Measuring the Difference Between Two Waveforms
(5) Set the WRITE bit for write the CAL_OUT field.
(8) Clear the WRITE bit.
(6) Set waveform frequency for 512Hz.
(7) Enable the calibration waveform
output.
31 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
A positive calibration value of ‘1’ will add 2 × 64 = 128 clock ticks hourly, thus reducing the number of WCO clock ticks needed to count that hour. Therefore, a calibration value of ‘1’ represents a correction of (2 × 64) / (32,768 × 60 × 60) = 1.085 ppm. The 6-bit calibration value field can hold values up to 63, but because the calibration counter is reloaded every hour, only values up to 60 can effectively be used. This gives a calibration range of ± 60 × 1.085 ppm = ± 65.1 ppm.
The CALIB_SIGN bit determines the direction of correction. A value of ‘0’ represents negative calibration, which will remove pulses and thus slow down real-time tracking by RTC function. A value of 1 represents positive calibration.
Figure 8 shows an example flow to calibrate WCO.
Start
Check READ Bit Status
(1)
(2)
(3)
(4)
(5)
Set the WRITE bit to Prepare for
the Update of Calibration Value
WRITE the Calibration Field
Clear WRITE Bit
End
Check RTC Busy Status
(6)
WRITE the Calibration Sign
Field
Figure 8 Example Flow to Calibrate WCO
Before performing the following steps, it is necessary to set the WCO input clock and RTC_CAL pin output of RTC as mentioned in Capturing the WCO Waveform.
1. Check the busy status; wait until BACKUP_STATUS.RTC_BUSY = ‘0’ to ensure safe design.
1
2. Check the read status; if BACKUP_RTC_RW.READ is not ‘0’, clear the READ bit (BACKUP_RTC_RW.READ = ‘0’).
Then, wait until BACKUP_RTC_RW.READ = ‘0’ to ensure safe design.2
3. Set the WRITE bit to prepare for the update of the calibration value:
Write BACKUP_RTC_RW.WRITE = ‘1’ (Begin the Write operation).
4. Write the calibration value field:
Write BACKUP_CAL_CTL.CALIB_VAL = "value". In this example, +27.125 ppm of the WCO frequency error is adjusted.
27.125 ppm / 1.085 = 25
The calibration value is ‘25’. Write BACKUP_CAL_CTL.CALIB_VAL = ‘25’.
1
The subsequent calibration operation cannot be executed while executing the previous operation.
2
The subsequent writing operation cannot be executed while the READ bit is set.
32 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
5. Write the calibration sign field:
Write BACKUP_CAL_CTL.CALIB_SIGN = ‘1’. ‘1’ because the RTC clock needs to be speeded up in this example.
6. Clear the WRITE bit;
Write BACKUP_RTC_RW.WRITE = ‘0’ (End the Write operation).
The calibration correction is done by either adding (like in this example) or removing pulse counts from the oscillator divider each hour, which speeds up or slows down the clock respectively. After calibration starts, the calibration correction is performed hourly, starting at 59 minutes and 59 seconds the correction is applied as 64 ticks every 30 seconds until there have been 2 × BACKUP_CAL_CTL.CALIB_VAL adjustments.
Table 10 lists the parameters and Table 11 lists function of the configuration part in SDL to set the calibration
value of RTC.
Table 10 List of RTC to Set the Calibration Value Parameters
Parameters
Description
Value
CALIB_VALUE
Calibration value for absolute frequency. Each step causes 128 ticks to be added or removed each hour.
25ul
CY_EN_RTC_CALIB_SIGN_POSITIVE
0: Negative sign: Removes pulses (it takes more clock ticks to count one second)
1: Positive sign: Adds pulses (it takes less clock ticks to count one second)
1
CY_EN_RTC_CAL_SEL_CAL512
Select calibration wave output signal
0: 512-Hz wave, not affected by calibration setting.
1: reserved 2: 2-Hz wave, includes the effect
of the calibration setting. 3: 1-Hz wave, includes the effect
of the calibration setting.
0
Table 11 List of RTC to Set the Calibration Value Function
Function
Description
Value
Cy_Rtc_CalibrationControlEnable (uint8_t calib_val,
cy_en_rtc_calib_sign_t calib_sign, cy_en_rtc_cal_sel_t cal_sel)
Set calibration control register and enable to calibration wave form output
calib_val:. Calibration value for absolute frequency.
calib_sign: Calibration sign cal_sel: Select calibration wave
output signal
CALIB_VALUE = 25ul, CY_EN_RTC_CALIB_SIGN_PO SITIVE= 0, CY_EN_RTC_CAL_SEL_CAL51 2 = 0
Code Listing 28 shows an example program to set the calibration value of RTC.
33 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 28 Example Program to Set the Calibration Value
/* Configure the RTC_CAL pin definition (P1_2)pin */
#define RTC_CAL_PIN P1_2_SRSS_CAL_WAVE #define USER_PORT GPIO_PRT1 #define USER_PIN 2
/* Setting value for calibration definition */
#define CALIB_VALUE 25ul
/* RTC configuration */
cy_stc_rtc_config_t const RTC_config = { /* Initiate time and date */ .sec = RTC_INITIAL_DATE_SEC, .min = RTC_INITIAL_DATE_MIN, .hour = RTC_INITIAL_DATE_HOUR, .hrMode = RTC_INITIAL_DATE_HOUR_FORMAT, .dayOfWeek = RTC_INITIAL_DATE_DOW, .date = RTC_INITIAL_DATE_DOM, .month = RTC_INITIAL_DATE_MONTH, .year = RTC_INITIAL_DATE_YEAR, };
/* RTC_CAL pin configuration */
cy_stc_gpio_pin_config_t user_led_port_pin_cfg = { .outVal = 0ul, .driveMode = CY_GPIO_DM_STRONG_IN_OFF, .hsiom = RTC_CAL_PIN, .intEdge = 0ul, .intMask = 0ul, .vtrip = 0ul, .slewRate = 0ul, .driveSel = 0ul,
};
int main(void) { cy_en_rtc_status_t retVal; uint8_t retStatus; uint32_t interruptState;
SystemInit();
__enable_irq(); /* Enable global interrupts. */
/* Set the WCO as the clock source to the RTC block */ retStatus = Cy_SysClk_WcoEnable(100ul); if(retStatus == CY_SYSCLK_SUCCESS) { Cy_Rtc_clock_source(CY_RTC_CLK_SRC_WCO); }
/* Configure the RTC_CAL pin */ Cy_GPIO_Pin_Init(USER_PORT, USER_PIN, &user_led_port_pin_cfg);
/* Wait for initial setting */ while(Cy_Rtc_Init(&RTC_config) != CY_RET_SUCCESS);
/* Check for RTC busy status */ while(Cy_Rtc_GetSyncStatus()==CY_RTC_BUSY);
/* Check for RTC read bit clear */ if(Cy_Rtc_IsReadBitSet()==1) { Cy_Rtc_ClearReadBit(); }
/* Check for read bit status */
Configure the RTC_CAL pin
Set the RTC initial value. The initialization part is omitted. See Code Listing 4.
Set the WCO clock source to the RTC. See Code Listing 29.
Configuration for RTC_CAL in the GPIO. See Table 7.
Check RTC busy status. See Code Listing 30.
Check READ bit status. See Code Listing 31,
Code Listing 32.
Configure initial time and date parameters.See Table 4.
Definition for RTC_CAL.
Definition for calibration value
34 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 28 Example Program to Set the Calibration Value
while(Cy_Rtc_IsReadBitSet()==1);
/* Set to RTC write bit */ interruptState = Cy_SysLib_EnterCriticalSection(); retVal = Cy_Rtc_WriteEnable(CY_RTC_WRITE_ENABLED); if(retVal == CY_RTC_SUCCESS) {
/* Set calibartion value and sign */ Cy_Rtc_CalibrationControlEnable(CALIB_VALUE, CY_EN_RTC_CALIB_SIGN_POSITIVE, CY_EN_RTC_CAL_SEL_CAL512); /* Clear the RTC Write bit */ Cy_Rtc_WriteEnable(CY_RTC_WRITE_DISABLED); } Cy_SysLib_ExitCriticalSection(interruptState);
for(;;) {
} }

2.4.5 Example Program to Measuring the WCO Waveform in Driver Part

Code Listing 29 to Code Listing 34 show an example program to measure the WCO waveform in the driver
part.
Code Listing 29 Example Program to RTC Input Clock Source Set in Driver Part
void Cy_Rtc_clock_source(cy_en_rtc_clock_src_t clock_source) { BACKUP->unCTL.stcField.u2CLK_SEL = clock_source; }
Code Listing 30 Example Program to Get Sync Status in Driver Part
uint32_t Cy_Rtc_GetSyncStatus(void) { return((_FLD2BOOL(BACKUP_STATUS_RTC_BUSY, BACKUP->unSTATUS.u32Register)) ? CY_RTC_BUSY : CY_RTC_AVAILABLE); }
Code Listing 31 Example Program to Check the READ Bit Status in Driver Part
bool Cy_Rtc_IsReadBitSet(void) { if(BACKUP->unRTC_RW.stcField.u1READ == 0ul) { return false; } else { return true; } }
Set the WRITE bit to prepare for the update of the
calibration value. See Code Listing 33.
WRITE the calibration value and calibration sign filed. See Code Listing 34.
Clear the WRITE bit. See Code Listing 32 .
Set the WCO clock source to the RTC.
(1) Check RTC busy status.
(2) Check READ bit status
35 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 32 Example Program to Clear the READ Bit in Driver Part
cy_en_rtc_status_t Cy_Rtc_ClearReadBit(void) { BACKUP->unRTC_RW.stcField.u1READ = 0ul;
return(CY_RTC_SUCCESS); }
Code Listing 33 Example Program to Write Enable in Driver Part
cy_en_rtc_status_t Cy_Rtc_WriteEnable(uint32_t writeEnable) { cy_en_rtc_status_t retVal = CY_RTC_INVALID_STATE;
if(writeEnable == CY_RTC_WRITE_ENABLED) { /* RTC Write bit set is possible only in condition that CY_RTC_BUSY bit = 0
* or RTC Read bit is not set */
if((CY_RTC_BUSY != Cy_Rtc_GetSyncStatus()) && (!_FLD2BOOL(BACKUP_RTC_RW_READ, BACKUP-> unRTC_RW.u32Register))) { BACKUP->unRTC_RW.u32Register |= BACKUP_RTC_RW_WRITE_Msk; retVal = CY_RTC_SUCCESS; } } else { /* Clearing Write Bit to complete write procedure */
BACKUP->unRTC_RW.u32Register &= ((uint32_t) ~BACKUP_RTC_RW_WRITE_Msk);
/* Delay to guarantee data write after clearing write bit */
Cy_SysLib_DelayUs(CY_RTC_DELAY_WRITE_US);
retVal = CY_RTC_SUCCESS; }
return(retVal); }
Code Listing 34 Example Program to Set the Calibration Control Enable in Driver Part
cy_en_rtc_status_t Cy_Rtc_CalibrationControlEnable(uint8_t calib_val, cy_en_rtc_calib_sign_t calib_sign, cy_en_rtc_cal_sel_t cal_sel) { if(BACKUP->unRTC_RW.stcField.u1WRITE == 0) { // Writes are ignored unless Write bit is set return CY_RTC_INVALID_STATE; }
un_BACKUP_CAL_CTL_t tmpBackupCalCtl = {0ul}; tmpBackupCalCtl.stcField.u6CALIB_VAL = calib_val; tmpBackupCalCtl.stcField.u1CALIB_SIGN = (uint32_t)calib_sign; tmpBackupCalCtl.stcField.u2CAL_SEL = (uint32_t)cal_sel; tmpBackupCalCtl.stcField.u1CAL_OUT = 1ul; // Output enable for wave signal for calibration and allow CALIB_VAL to be written. BACKUP->unCAL_CTL.u32Register = tmpBackupCalCtl.u32Register;
return CY_RTC_SUCCESS; }
This function clears the READ bit to 0.
(3) Set the WRITE bit to prepare for the update of the calibration value.
(6) Clear the WRITE bit.
(4) WRITE the calibration value field
(5) WRITE the calibration sign filed
36 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview

2.4.6 Confirming the Accuracy of the WCO Frequency after Calibration

The WCO waveform (512 Hz) is not affected even if the calibration values (BACKUP_CAL_CTL.CALIB_VAL and BACKUP_CAL_CTL.CALIB_SIGN) are changed. However, 1-Hz and 2-Hz calibration waveforms are affected by the current calibration value. As Figure 9 shows, the 512-Hz divider is not routed through the calibration logic. You can verify the accuracy of the WCO frequency by measuring the 1-Hz or the 2-Hz waveform.
RTC_CAL
WCO
512 Hz Divider
1 Hz
Divider
2 Hz
Divider
Calibration Logic With
BACKUP_CAL_CRTL.CAL_SEL
BACKUP_CAL_CRTL.CALIB_VAL BACKUP_CAL_CRTL.CALIB_SIGN
Waveform Output
Figure 9 Clock Select Block Diagram
Figure 10 shows an example flow to confirm the accuracy of the WCO frequency after calibration.
Start
Check READ Bit Status
(1)
(2)
(3)
(4)
(5)
Set WRITE Bit to Prepare to
Change Calibration Frequency
Disable Calibration Waveform
Clear WRITE Bit
End
Check RTC Busy Status
Configure RTC_CAL Pin
(6)
Select Waveform Frequency
(7)
Enable Calibration Waveform
(8)
Figure 10 Example Flow to Confirm Accuracy of WCO Frequency after Calibration
37 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
The following steps explain how to output the WCO frequency of 1-Hz waveform to confirm the accuracy post­calibration:
1. Configure the RTC_CAL pin; see the I/O Port chapter in the Architecture TRM.
2. Check the busy status; wait until BACKUP_STATUS.RTC_BUSY = ‘0’ to ensure safe design.
1
3. Check the read status; If BACKUP_RTC_RW.READ is not ‘0’, clear the READ bit (BACKUP_RTC_RW.READ = ‘0’).
Then wait until BACKUP_RTC_RW.READ = ‘0’ to ensure safe design.2
4. Set the WRITE bit to prepare to change the calibration frequency;
Write BACKUP_RTC_RW.WRITE = ‘1’ (Begin the Write operation).
5. Disable the calibration waveform:
Write BACKUP_CAL_CTL.CAL_OUT = ‘0’ (Disable calibration waveform output).
6. Select the waveform frequency:
Write BACKUP_CAL_CTL.CAL_SEL = ‘3’(1-Hz).
7. Enable the calibration waveform:
Write BACKUP_CAL_CTL.CAL_OUT = ‘1’ (Enable Calibration waveform output).
8. Clear the WRITE bit:
Write BACKUP_RTC_RW.WRITE = ‘0’ (End the Write operation).
Then, 1-Hz waveform can now be observed at the RTC_CAL pin. These waveforms are calibrated with BACKUP_CAL_CTL.CALIB_VAL. By measuring the waveform with an external equipment (for example, a calibrated oscilloscope), you can check the effectiveness of the calibration.
Table 12 lists the parameters and Table 13 lists the function of the configuration part in SDL to change the
output frequency of the calibration waveform.
Table 12 List of RTC to Change Output Frequency of Calibration Waveform Parameters
Parameters
Description
Value
CALIB_VALUE
Calibration value for absolute frequency. Each step causes 128 ticks to be added or removed each hour.
25ul
CY_EN_RTC_CALIB_SIGN_POSITIVE
0: Negative sign: Removes pulses (it takes more clock ticks to count one second)
1: Positive sign: Add pulses (it takes less clock ticks to count one second)
1
CY_EN_RTC_CAL_SEL_CAL1
Select calibration wave output signal
0: 512-Hz wave, not affected by calibration setting.
1: reserved 2: 2-Hz wave, includes the effect
of the calibration setting. 3: 1-Hz wave, includes the effect
of the calibration setting.
3
1
The subsequent calibration operation cannot be executed while executing the previous operation.
2
The subsequent writing operation cannot be executed while the READ bit is set.
38 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
Table 13 List of RTC to Change Output Frequency of Calibration Waveform Functions
Functions
Description
Value
Cy_Rtc_CalibrationControlDisable (void)
Disable calibration waveform output
-
Cy_Rtc_CalibrationControlEnable (uint8_t calib_val,
cy_en_rtc_calib_sign_t calib_sign, cy_en_rtc_cal_sel_t cal_sel)
Set calibration control register and enable to calibration wave form output
calib_val:. Calibration value for absolute frequency.
calib_sign: Calibration sign
cal_sel: Select calibration wave output signal
CALIB_VALUE = 25ul, CY_EN_RTC_CALIB_SIGN_POSITIVE= 1, CY_EN_RTC_CAL_SEL_CAL1 = 3
Code Listing 35 shows an example program to change the output frequency of the calibration waveform.
Code Listing 35 Example Program to Change Output Frequency of Calibration Waveform
/* Configure the RTC_CAL pin definition (P1_2)pin */
#define RTC_CAL_PIN P1_2_SRSS_CAL_WAVE #define USER_PORT GPIO_PRT1 #define USER_PIN 2
/* Setting value for calibration definition */
#define CALIB_VALUE 25ul
/* RTC configuration */
cy_stc_rtc_config_t const RTC_config = { /* Initiate time and date */ .sec = RTC_INITIAL_DATE_SEC, .min = RTC_INITIAL_DATE_MIN, .hour = RTC_INITIAL_DATE_HOUR, .hrMode = RTC_INITIAL_DATE_HOUR_FORMAT, .dayOfWeek = RTC_INITIAL_DATE_DOW, .date = RTC_INITIAL_DATE_DOM, .month = RTC_INITIAL_DATE_MONTH, .year = RTC_INITIAL_DATE_YEAR, };
/* RTC_CAL pin configuration */
cy_stc_gpio_pin_config_t user_led_port_pin_cfg = { .outVal = 0ul, .driveMode = CY_GPIO_DM_STRONG_IN_OFF, .hsiom = RTC_CAL_PIN, .intEdge = 0ul, .intMask = 0ul, .vtrip = 0ul, .slewRate = 0ul, .driveSel = 0ul,
};
int main(void) { cy_en_rtc_status_t retVal; uint8_t retStatus; uint32_t interruptState;
Configuration for RTC_CAL in the GPIO. See Table 7.
Configure initial time and date parameters. See Table 4.
Definition for RTC_CAL.
Definition for calibration value
39 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 35 Example Program to Change Output Frequency of Calibration Waveform
SystemInit();
__enable_irq(); /* Enable global interrupts. */
/* Set the WCO as the clock source to the RTC block */ retStatus = Cy_SysClk_WcoEnable(100ul); if(retStatus == CY_SYSCLK_SUCCESS) { Cy_Rtc_clock_source(CY_RTC_CLK_SRC_WCO); }
/* Configure the RTC_CAL pin (P1_2) */ Cy_GPIO_Pin_Init(USER_PORT, USER_PIN, &user_led_port_pin_cfg);
/* Wait for initial setting */ while(Cy_Rtc_Init(&RTC_config) != CY_RET_SUCCESS);
/* Check for RTC busy status */ while(Cy_Rtc_GetSyncStatus()==CY_RTC_BUSY);
/* Check for RTC read bit clear */ if(Cy_Rtc_IsReadBitSet()==1) { Cy_Rtc_ClearReadBit(); }
/* Check for read bit status */ while(Cy_Rtc_IsReadBitSet()==1);
/* Set to RTC write bit */ interruptState = Cy_SysLib_EnterCriticalSection(); retVal = Cy_Rtc_WriteEnable(CY_RTC_WRITE_ENABLED); if(retVal == CY_RTC_SUCCESS) {
/* Disable calibration waveform output */ Cy_Rtc_CalibrationControlDisable();
/* Change waveform frequency for 1Hz */ Cy_Rtc_CalibrationControlEnable(CALIB_VALUE, CY_EN_RTC_CALIB_SIGN_POSITIVE, CY_EN_RTC_CAL_SEL_CAL1); /* Clear the RTC Write bit */ Cy_Rtc_WriteEnable(CY_RTC_WRITE_DISABLED); } Cy_SysLib_ExitCriticalSection(interruptState);
for(;;) {
} }
Set the clock source to the RTC. See Code Listing 29.
(1) Configure the RTC_CAL pin
Set the RTC initial value. The initialization part is omitted. See Code Listing 4.
Check RTC busy status. See Code Listing 36.
Check READ bit status. See Code Listing 37, Code
Listing 38.
Set the WRITE bit for changing the calibration
waveform. See Code Listing 39.
Disable the calibration waveform. See Code Listing 40.
Clear the WRITE bit. See Code Listing 39 .
Select the waveform frequency and enable the
calibration waveform. See Code Listing 41 .
40 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview
2.4.7 Example Program to Confirm Accuracy of WCO Frequency after
Calibration in Driver Part
Code Listing 36 to Code Listing 41 show an example program to confirm the accuracy of the WCO frequency
after calibration in the driver part.
Code Listing 36 Example Program to Get Sync Status in Driver Part
uint32_t Cy_Rtc_GetSyncStatus(void) { return((_FLD2BOOL(BACKUP_STATUS_RTC_BUSY, BACKUP->unSTATUS.u32Register)) ? CY_RTC_BUSY : CY_RTC_AVAILABLE); }
Code Listing 37 Example Program to Check the READ Bit Status in Driver Part
bool Cy_Rtc_IsReadBitSet(void) { if(BACKUP->unRTC_RW.stcField.u1READ == 0ul) { return false; } else { return true; } }
Code Listing 38 Example Program to Clear the READ bit in Driver Part
cy_en_rtc_status_t Cy_Rtc_ClearReadBit(void) { BACKUP->unRTC_RW.stcField.u1READ = 0ul;
return(CY_RTC_SUCCESS); }
Code Listing 39 Example Program to Write Enable in Driver Part
cy_en_rtc_status_t Cy_Rtc_WriteEnable(uint32_t writeEnable) { cy_en_rtc_status_t retVal = CY_RTC_INVALID_STATE;
if(writeEnable == CY_RTC_WRITE_ENABLED) { /* RTC Write bit set is possible only in condition that CY_RTC_BUSY bit = 0
* or RTC Read bit is not set */
if((CY_RTC_BUSY != Cy_Rtc_GetSyncStatus()) && (!_FLD2BOOL(BACKUP_RTC_RW_READ, BACKUP-> unRTC_RW.u32Register))) { BACKUP->unRTC_RW.u32Register |= BACKUP_RTC_RW_WRITE_Msk; retVal = CY_RTC_SUCCESS; } } else { /* Clearing Write Bit to complete write procedure */
(4) Set the WRITE bit for changing the
calibration waveform
This function clears the READ bit to 0.
(3) Check READ bit status.
(2) Check RTC busy status.
41 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Operation Overview Code Listing 39 Example Program to Write Enable in Driver Part
BACKUP->unRTC_RW.u32Register &= ((uint32_t) ~BACKUP_RTC_RW_WRITE_Msk);
/* Delay to guarantee data write after clearing write bit */
Cy_SysLib_DelayUs(CY_RTC_DELAY_WRITE_US);
retVal = CY_RTC_SUCCESS; }
return(retVal); }
Code Listing 40 Example Program to Disable the Calibration Waveform Output in Driver Part
cy_en_rtc_status_t Cy_Rtc_CalibrationControlDisable(void) { if(BACKUP->unRTC_RW.stcField.u1WRITE == 0) { // Writes are ignored unless Write bit is set return CY_RTC_INVALID_STATE; }
BACKUP->unCAL_CTL.stcField.u1CAL_OUT = 0ul; // Output disable for wave signal for calibration
return CY_RTC_SUCCESS; }
Code Listing 41 Example Program to Set the Calibration Control Enable in Driver Part
cy_en_rtc_status_t Cy_Rtc_CalibrationControlEnable(uint8_t calib_val, cy_en_rtc_calib_sign_t calib_sign, cy_en_rtc_cal_sel_t cal_sel) { if(BACKUP->unRTC_RW.stcField.u1WRITE == 0) { // Writes are ignored unless Write bit is set return CY_RTC_INVALID_STATE; }
un_BACKUP_CAL_CTL_t tmpBackupCalCtl = {0ul}; tmpBackupCalCtl.stcField.u6CALIB_VAL = calib_val; tmpBackupCalCtl.stcField.u1CALIB_SIGN = (uint32_t)calib_sign; tmpBackupCalCtl.stcField.u2CAL_SEL = (uint32_t)cal_sel; tmpBackupCalCtl.stcField.u1CAL_OUT = 1ul; // Output enable for wave signal for calibration and allow CALIB_VAL to be written. BACKUP->unCAL_CTL.u32Register = tmpBackupCalCtl.u32Register;
return CY_RTC_SUCCESS; }
(6) Select the waveform frequency
(7) Enable the calibration waveform
(5) Disable the calibration waveform
(8) Clear the WRITE bit.
42 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family

Glossary

Glossary
Terms
Description
RTC function
Function of the RTC logic.
RTC value
Time tracked by the RTC function. See the Real-Time Clock section in the Real-Time Clock chapter of the Architecture TRM for details.
Calibration feature
Feature to correct any frequency error of the RTC values.
Integer values
Whole numbers and not Binary Coded Decimal (BCD).
Leap-year correction
The RTC implements automatic leap year correction for the Date field (day of the month). See the Real-Time Clock section in the Real-Time Clock chapter of the Architecture TRM for details.
ILO
Internal Low-speed Oscillator is the embedded oscillator inside Traveo II device. See the Clocking System chapter of the Architecture TRM for details.
CLK_LF
Low-Frequency Clock is selectable. See the Clocking System chapter of the Architecture TRM for details.
WCO
Watch Crystal Oscillator is the external crystal that is input from the external WCO_IN and WCO_OUT pins. See the Clocking System chapter of the Architecture TRM for details.
LPECO
Low-power external crystal oscillator is the external crystal that is input from the external LPECO_IN and LPECO_OUT pins. See the Clocking System chapter of the Architecture TRM for details.
Calibration waveform
The signal outputs from the RTC_CAL pin for adjusting the RTC. See the WCO/LPECO Calibration section in the Real-Time Clock chapter of the
Architecture TRM for details.
Ideal waveform
Waveform that has an accurate frequency
Clock screen
The dot-matrix display or the segment display that shows the actual time in a vehicle.
User system
User-developed electronic board/system where Traveo II device is mounted.
User firmware
User-developed software that runs on the CPU.
Local variables
Variables used by user firmware.
User buffer
The local variables assigned by user firmware in RAM.
AHB-Lite bus interface
The bus interface between CPU Subsystem and Peripheral interconnect. See the Top-Level Architecture section in the Introduction chapter of the Architecture TRM for details.
User registers
Resisters that can be accessed by user firmware. Read and write operations are possible. However, values do not always reflect the latest data. See the Real-Time Clock section in the Real-Time Clock chapter of the Architecture TRM for details.
RTC registers
Resisters that can be accessed by hardware. Read and write operations are not possible by user firmware. Values always reflect the latest data. See the Real-Time Clock section in the Real-Time Clock chapter of the
Architecture TRM for details.
43 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family
Glossary Terms
Description
RTC fields
Bit fields of RTC values in user registers and RTC registers. See the Real­Time Clock section in the Real-Time Clock chapter of the Architecture
TRM for details.
Alarm fields
Bit fields of alarm values in user registers and RTC registers. See the Real-Time Clock section in the Real-Time Clock chapter of the
Architecture TRM for details.
Config fields
Bit fields of configuration bits in user registers and RTC registers. See the Real-Time Clock section in the Real-Time Clock chapter of the
Architecture TRM for details.
WCO device and logic
WCO device is an external crystal oscillator. WCO logic is a circuit inside Traveo II device.
LPECO device and logic
LPECO device is an external crystal oscillator. LPECO logic is a circuit inside Traveo II device.
Power mode / Device power mode
Traveo II family has several power modes in the order of decreasing power consumption. See the Device Power Modes chapter of the
Architecture TRM for details.
Alarm function
An interrupt is generated when the RTC fields and the alarm fields match. See the “Alarm Feature” section in the Real-Time Clock chapter of the Architecture TRM for details.
Interval time
A time of periodic interrupt.
Power on reset
Reset operation after power on sequence. See the Rest System chapter of the Architecture TRM for details.
Waking up
Restarting user firmware from stand-by mode, Sleep, Low-Power Sleep, DeepSleep, Hibernate. See the Device Power Modes chapter of the Architecture TRM for details.
44 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family

Related Documents

Related Documents
The following are the Traveo II family series datasheets and Technical Reference Manuals. Contact Technical
Support to obtain these documents.
[1] Device datasheet
CYT2B7 Datasheet 32-Bit Arm
®
Cortex®-M4F Microcontroller Traveo™ II Family
CYT2B9 Datasheet 32-Bit Arm
®
Cortex®-M4F Microcontroller Traveo™ II Family
CYT4BF Datasheet 32-Bit Arm
®
Cortex®-M7 Microcontroller Traveo™ II Family
CYT4DN Datasheet 32-Bit Arm
®
Cortex®-M7 Microcontroller Traveo™ II Family
CYT3BB/4BB Datasheet 32-Bit Arm
®
Cortex®-M7 Microcontroller Traveo™ II Family
[2] Body Controller Entry Family
Traveo™ II Automotive Body Controller Entry Family Architecture Technical Reference Manual (TRM)
Traveo™ II Automotive Body Controller Entry Registers Technical Reference Manual (TRM) for CYT2B7
Traveo™ II Automotive Body Controller Entry Registers Technical Reference Manual (TRM) for CYT2B9
[3] Body Controller High Family
Traveo™ II Automotive Body Controller High Family Architecture Technical Reference Manual (TRM)
Traveo™ II Automotive Body Controller High Registers Technical Reference Manual (TRM) for CYT4BF
Traveo™ II Automotive Body Controller High Registers Technical Reference Manual (TRM) for CYT3BB/4BB
[4] Cluster 2D Family
Traveo™ II Automotive Cluster 2D Family Architecture Technical Reference Manual (TRM)
Traveo™ II Automotive Cluster 2D Registers Technical Reference Manual (TRM)
[5] Application Note
AN219842 – How to Use Interrupt in Traveo II
45 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family

Other References

Other References
Cypress provides the Sample Driver Library (SDL) including startup as sample software to access various peripherals. SDL also serves as a reference, to customers, for drivers that are not covered by the official AUTOSAR products. The SDL cannot be used for production purposes as it does not qualify to any automotive standards. The code snippets in this application note are part of the SDL. Contact Technical Support to obtain the SDL.
46 of 47 002-20190 Rev. *D 2020-12-15
How to Use RTC in Traveo II Family

Revision history

Revision history
Document version
Date of release
Description of changes
**
01/15/2019
New Application Note
*A
03/15/2019
Added target parts number (CYT4B series)
*B
07/30/2019
Added descriptions of LPECO and target parts number (CYT4D series).
*C
03/10/2020
Changed target parts number (CYT2/ CYT4 series). Added target parts number (CYT3 series).
*D
2020-12-15
Added flowchart and example codes Moved to Infineon Template
Trademarks
All referenced product or service names and trademarks are the property of their respective owners.
Edition 2020-12-15 Published by Infineon Technologies AG 81726 Munich, Germany
© 2019-2020 Infineon Technologies AG. All Rights Reserved.
Do you have a question about this document?
Go to www.cypress.com/support
Document reference 002-20190 Rev. *D
IMPORTANT NOTICE
The information contained in this application note is given as a hint for the implementation of the product only and shall in no event be regarded as a description or warranty of a certain functionality, condition or quality of the product. Before implementation of the product, the recipient of this application note must verify any function and other technical information given herein in the real application. Infineon Technologies hereby disclaims any and all warranties and liabilities of any kind (including without limitation warranties of non­infringement of intellectual property rights of any third party) with respect to any and all information given in this application note.
The data contained in this document is exclusively intended for technically trained staff. It is the
responsibility of customer’s technical departments
to evaluate the suitability of the product for the intended application and the completeness of the product information given in this document with respect to such application.
For further information on the product, technology, delivery terms and conditions and prices please contact your nearest Infineon Technologies office (www.infineon.com).
WARNINGS
Due to technical requirements products may contain dangerous substances. For information on the types in question please contact your nearest Infineon Technologies office.
Except as otherwise explicitly approved by Infineon Technologies in a written document signed by authorized representatives of Infineon
Technologies, Infineon Technologies’ products may
not be used in any applications where a failure of the product or any consequences of the use thereof can reasonably be expected to result in personal injury.
Loading...