![ARTERY AT32F435 Series Скачать руководство пользователя страница 343](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592343.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 343
Rev 2.03
17.3.5 Reference clock detection
The calendar update can be synchronized (not used in low-power modes) to a reference clock (usually
the mains 50 or 60 Hz) with a higher precision. This reference clock is used to calibrate the precision of
the calendar update frequency (1 Hz)
When it is enabled, the reference clock edge detection is performed during the first 7 ck_a periods
around each of the calendar updates. When detected, the edge is used to update calendar values, and
3 ck_a periods are used for subsequent calendar updates. Each time the reference clock edge is
detected, the divider A value is forced to reload, making the reference clock and the 1 Hz clock are
aligned. If the 1 Hz clock has a slight shift, a more accurate reference clock can be used to fine-tune the
1 Hz clock so that it is aligned with the reference clock. If no reference clock edge is detected, the
calendar is updated based on ERTC’s original clock source.
Note: Once the reference clock detection is enabled, the DIVA and DIVB must be kept at its respective
reset value (0x7F and 0xFF respectively). The clock synchronization cannot be used in conjunction with
the coarse digital calibration.
17.3.6 Time stamp function
When time stamp event is detected on the tamper pin (valid edge is detected), the current calendar
value will be stored to the time stamp register.
When a time stamp event occurs, the time stamp flag bit (TSF) in the ERTC_STS register will be set. If
a new time stamp event is detected when time stamp flag (TSF) is already set, then the time stamp
overflow flag (TSOF) will be set, but the time stamp registers will remain the result of the last event. By
setting the TSIEN bit, an interrupt can be generated when a time stamp event occurs.
Usage of time stamp:
1. How to enable time stamp when a valid edge is detected on a tamper pin
Select a time stamp in by setting the TSPIN bit
Select a rising edge or falling edge to trigger time stamp by setting the TSEDG bit
Enable time stamp by setting TSEN=1
2.
How to save time stamp on a tamper event
Configure tamper detection registers
Enable tamper detection time stamp by setting TPTSEN=1
Note: The TSF bit will be set after two ck_a cycles following a time stamp event. It is suggested that
users poll TSOF bit when the TSF is set.
17.3.7 Tamper detection
The ERTC has two tamper detection modes: TAMP1 and TAMP2. They can be configured as a level
detection with filter or edge detection respectively. TAMP1 can select either ERTC_MUX or
ERTC_MUX2 through the TSPIN bit, while the TAMP2 can only select ERTC_MUX2.
The TP1F or TP2F will be set when a valid tamper event is detected. An interrupt will also be generated
if a tamper detection interrupt is enabled. If the TPTSEN bit is already set, a time stamp event will be
generated accordingly. Once a tamper event occurs, the battery powered registers will be reset so as
to ensure data security in the battery powered domain.
How to configure edge detection
1.
Select edge detection by setting TPFLT=00, and select a valid edge (either TP1EDG or TP2EDG)
2.
According to your needs, configure whether to activate a time stamp on a tamer event (TPTSEN=1)
3.
According to your needs, enable a tamper detection interrupt (TPIEN=1)
4.
To use TAMP1 mode, select ERTC_MUX1 or ERTC_MUX2 (through the TP1PIN bit), and enable
TAMP1 (setting TP1EN=1 ); To use TAMP2 mode, just need enable TAMP2 (TP2EN=1)
How to configure level detection with filter
1.
Select level detection with filter, and valid level sampling times (TPFLT
≠
00)
2.
Select tamper detection valid level (through TP1EDG or TP2EDG)
3.
Select tamper detection sampling frequency (through the TPFREQ bit )