Part 1
요약·해설
Boot부터 register, aligned clock, 두 alarm과 ppm 오차까지 11단계 출력을 해설합니다.
2 ppm
Battery backed
Second · Minute
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
9634AB0C3C2181D9232FCCA6BAE936FED03454BC6B8A6B9E6C28305CF2A889A4
.. zephyr:code-sample:: ds3231
:name: DS3231 TCXO RTC
:relevant-api: counter_interface
Interact with a DS3231 real-time clock using the counter API and dedicated driver API.
Overview
********
The `DS3231`_ temperature-compensated real-time clock is a
high-precision (2 ppm) battery backed clock that maintains civil time
and supports alarms. The `Chronodot`_ breakout board can be used to
test it.
Annotated Example Output
************************
The sample first displays the boot banner, board name and
frequency of the local clock used for synchronization, and whether the
DS3231 has recorded a loss-of-oscillator::
***** Booting Zephyr OS build zephyr-v1.14.0-2409-g322d53aedaa0 *****
DS3231 on particle_xenon syncclock 1000 Hz
.
DS3231 has not experienced an oscillator fault
Next, information about the device as a counter is displayed. The
counter value is read, and its value formatted as the date, time, day of
week, and day of year (19 July 2019 is a Friday, and is the 200th day of
2019)::
Counter at 0x20001a58
Max top value: 4294967295 (ffffffff)
2 channels
1 Hz
Top counter value: 4294967295 (ffffffff)
Now 1563512509: 2019-07-19 05:01:49 Fri 200
The DS3231 control and status register values are displayed::
DS3231 ctrl 04 ; ctrl_stat 08
Next, if the sample application option ``CONFIG_APP_SET_ALIGNED_CLOCK``
is set, the civil time will be advanced to the start of the next hour,
and the clock will be set to align that time with the time of the boot,
which in the output below is 34 ms in the past. The time required to
synchronize the clock is 967 ms, and the whole second value of one
second past the hour is written at 1000 ms local uptime::
Set 2019-07-19 06:00:00.034000000 Fri 200 at 34 ms past: 0
Synchronize final: 0 0 in 967 ms
wrote sync 0: 1563516001 0 at 1000
Then a synchronization point is read. This takes 894 ms (it must align
to an RTC one-second rollover)::
Synchronize init: 0
Synchronize complete in 894 ms: 0 0
.
read sync 0: 1563516002 0 at 2000
The alarm configuration is read from non-volatile memory and displayed.
See the ``maxim_ds3231.h`` for interpretation of the integer value and
flags::
Alarm 1 flags 0 at 254034017: 0
Alarm 2 flags e at 252374400: 0
Five seconds is added to the current time and the civil time
representation displayed. The second-resolution alarm is configured to
fire at that time on the current day-of-week. The minute-resolution
alarm is configured to fire once per minute::
Min Sec base time: 2019-07-19 06:00:07 Fri 200
Set sec alarm 90 at 1563516007 ~ 2019-07-19 06:00:07 Fri 200: 5
Set min alarm flags f at 1563516007 ~ 2019-07-19 06:00:07 Fri 200: 7
We're now 2.131 ms into the run, at which point the alarms are read back
and displayed. Alarms do not include date but can include day-of-week
or day-of-month; the date is selected to preserve that information::
2131 ms in: get alarms: 0 0
Sec alarm flags 10 at 252914407 ~ 1978-01-06 06:00:07 Fri 006
Min alarm flags e at 252374400 ~ 1977-12-31 00:00:00 Sat 365
The second-resolution alarm was signalled, and processed by the
application at 7.002 s into the run, as scheduled (plus callback
latency). The callback uses the counter alarm API to schedule a second
alarm in 10 seconds::
Sec signaled at 7002 ms, param 0x20000048, delay 1; set 7
The counter API callback is called at the correct time::
Counter callback at 17001 ms, id 0, ticks 1563516017, ud 0x20000048
From here on the sample sleeps except when the minute-resolution alarm
fires, at which point it displays the RTC time; the
nanosecond-resolution offset in seconds between the RTC time and the
local time; the local time from ``k_uptime_get()``; and the aggregate
error between local and RTC time measured in parts-per-million::
2019-07-19 06:01:00 Fri 200: adj 0.002000000, uptime 0:01:00.002, clk err 34 ppm
2019-07-19 06:02:00 Fri 200: adj 0.003000000, uptime 0:02:00.004, clk err 25 ppm
2019-07-19 06:03:00 Fri 200: adj 0.005000000, uptime 0:03:00.005, clk err 28 ppm
2019-07-19 06:04:00 Fri 200: adj 0.006000000, uptime 0:04:00.007, clk err 25 ppm
2019-07-19 06:05:00 Fri 200: adj 0.008000000, uptime 0:05:00.008, clk err 26 ppm
The output shows that the Zephyr system clock is running about 25 ppm
faster than civil time on this device. This amount of error is expected
for this target as the system time derives from a crystal oscillator
with a similar accuracy.
Building and Running
********************
Wire a Chronodot to one of the supported boards as specified in the
corresponding devicetree overlay.
* Particle Xenon
.. zephyr-app-commands::
:zephyr-app: samples/drivers/counter/maxim_ds3231
:board: particle-xenon
:goals: build
:compact:
* NXP Freedom K64F
.. zephyr-app-commands::
:zephyr-app: samples/drivers/counter/maxim_ds3231
:board: frdm_k64f
:goals: build
:compact:
* ST Nucleo L476RG
.. zephyr-app-commands::
:zephyr-app: samples/drivers/counter/maxim_ds3231
:board: nucleo_l476rg
:goals: build
:compact:
* EFR32 Mighty Gecko Thunderboard Sense 2
.. zephyr-app-commands::
:zephyr-app: samples/drivers/counter/maxim_ds3231
:board: sltb004a
:goals: build
:compact:
.. _DS3231:
https://www.maximintegrated.com/en/products/analog/real-time-clocks/DS3231.html
.. _Chronodot:
https://www.adafruit.com/product/255
Part 3
한국어 전문 번역
개요
DS3231 temperature-compensated real-time clock은 civil time을 유지하고 alarm을 지원하는, battery backup 기반의 고정밀 2ppm clock입니다. Chronodot breakout board로 시험할 수 있습니다.
주석을 단 예제 출력
Sample은 먼저 boot banner, board 이름, 동기화에 사용하는 local clock frequency, 그리고 DS3231에 oscillator loss 기록이 있는지를 표시합니다.
***** Booting Zephyr OS build zephyr-v1.14.0-2409-g322d53aedaa0 *****
DS3231 on particle_xenon syncclock 1000 Hz
.
DS3231 has not experienced an oscillator fault
다음으로 counter로서의 device 정보를 표시합니다. Counter 값을 읽은 뒤 날짜, 시간, 요일, 연중 일수 형식으로 나타냅니다. 2019년 7월 19일은 금요일이고 2019년의 200번째 날입니다.
Counter at 0x20001a58
Max top value: 4294967295 (ffffffff)
2 channels
1 Hz
Top counter value: 4294967295 (ffffffff)
Now 1563512509: 2019-07-19 05:01:49 Fri 200
DS3231 control register와 status register 값을 표시합니다.
DS3231 ctrl 04 ; ctrl_stat 08
다음으로 sample application option CONFIG_APP_SET_ALIGNED_CLOCK가 설정돼 있다면 civil time을 다음 정시의 시작으로 진행시킵니다. 그런 다음 이 시간을 boot 시각과 맞추도록 clock을 설정하는데, 아래 출력에서는 34ms 전 시각입니다. Clock 동기화에는 967ms가 필요하며, 정시에서 1초 지난 whole-second 값은 local uptime 1000ms 시점에 기록됩니다.
Set 2019-07-19 06:00:00.034000000 Fri 200 at 34 ms past: 0
Synchronize final: 0 0 in 967 ms
wrote sync 0: 1563516001 0 at 1000
그다음 synchronization point를 읽습니다. RTC의 1초 rollover에 맞춰야 하므로 894ms가 걸립니다.
Synchronize init: 0
Synchronize complete in 894 ms: 0 0
.
read sync 0: 1563516002 0 at 2000
Non-volatile memory에서 alarm 구성을 읽어 표시합니다. Integer 값과 flag의 해석은 maxim_ds3231.h를 참조하십시오.
Alarm 1 flags 0 at 254034017: 0
Alarm 2 flags e at 252374400: 0
현재 시각에 5초를 더하고 civil time 표현을 표시합니다. Second-resolution alarm은 현재 요일의 해당 시각에 발생하도록 구성하고, minute-resolution alarm은 매분 한 번 발생하도록 구성합니다.
Min Sec base time: 2019-07-19 06:00:07 Fri 200
Set sec alarm 90 at 1563516007 ~ 2019-07-19 06:00:07 Fri 200: 5
Set min alarm flags f at 1563516007 ~ 2019-07-19 06:00:07 Fri 200: 7
이제 실행 후 2.131ms 지점이며, 여기서 alarm을 다시 읽어 표시합니다. Alarm에는 date가 없지만 day-of-week 또는 day-of-month를 포함할 수 있으므로, 해당 정보를 보존하는 date를 선택합니다.
2131 ms in: get alarms: 0 0
Sec alarm flags 10 at 252914407 ~ 1978-01-06 06:00:07 Fri 006
Min alarm flags e at 252374400 ~ 1977-12-31 00:00:00 Sat 365
Second-resolution alarm은 예정대로 실행 후 7.002초에 신호를 보냈고 callback latency가 더해진 시점에 application이 처리했습니다. Callback은 counter alarm API를 사용해 10초 뒤 두 번째 alarm을 예약합니다.
Sec signaled at 7002 ms, param 0x20000048, delay 1; set 7
Counter API callback은 정확한 시각에 호출됩니다.
Counter callback at 17001 ms, id 0, ticks 1563516017, ud 0x20000048
이후 sample은 minute-resolution alarm이 발생할 때를 제외하면 sleep 상태로 있습니다. Alarm이 발생하면 RTC time, RTC time과 local time 사이의 nanosecond-resolution offset을 초 단위로 나타낸 값, k_uptime_get()에서 얻은 local time, 그리고 local time과 RTC time 사이의 누적 오차를 ppm 단위로 표시합니다.
2019-07-19 06:01:00 Fri 200: adj 0.002000000, uptime 0:01:00.002, clk err 34 ppm
2019-07-19 06:02:00 Fri 200: adj 0.003000000, uptime 0:02:00.004, clk err 25 ppm
2019-07-19 06:03:00 Fri 200: adj 0.005000000, uptime 0:03:00.005, clk err 28 ppm
2019-07-19 06:04:00 Fri 200: adj 0.006000000, uptime 0:04:00.007, clk err 25 ppm
2019-07-19 06:05:00 Fri 200: adj 0.008000000, uptime 0:05:00.008, clk err 26 ppm
출력은 이 device에서 Zephyr system clock이 civil time보다 약 25ppm 빠르게 동작함을 보여줍니다. System time이 비슷한 accuracy의 crystal oscillator에서 파생되므로 이 정도 오차는 이 대상에서 예상되는 범위입니다.
Build와 실행
지원 board에 맞는 devicetree overlay의 설명대로 Chronodot을 배선하십시오.
- Particle Xenon
west build -b particle-xenon samples/drivers/counter/maxim_ds3231
- NXP Freedom K64F
west build -b frdm_k64f samples/drivers/counter/maxim_ds3231
- ST Nucleo L476RG
west build -b nucleo_l476rg samples/drivers/counter/maxim_ds3231
- EFR32 Mighty Gecko Thunderboard Sense 2
west build -b sltb004a samples/drivers/counter/maxim_ds3231
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.