# SAM4S RTC

## Real-time Clock (RTC) User Interface

### Registers

Register Mapping
Address | Register | Name | Access | Reset
--- | --- | --- | --- | ---
0x400E1460 | Control Register | RTC_CR | read-write | 0x00000000
0x400E1464 | Mode Register | RTC_MR | read-write | 0x00000000
0x400E1468 | Time Register | RTC_TIMR | read-write | 0x00000000
0x400E146C | Calendar Register | RTC_CALR | read-write | 0x01A11020
0x400E1470 | Time Alarm Register | RTC_TIMALR | read-write | 0x00000000
0x400E1474 | Calendar Alarm Register | RTC_CALALR | read-write | 0x01010000
0x400E1478 | Status Register | RTC_SR | read-only | 0x00000000
0x400E147C | Status Clear Command Register | RTC_SCCR | write-only | -
0x400E1480 | Interrupt Enable Register | RTC_IER | write-only | -
0x400E1484 | Interrupt Disable Register | RTC_IDR | write-only | -
0x400E1488 | Interrupt Mask Register | RTC_IMR | read-only | 0x00000000
0x400E148C | Valid Entry Register | RTC_VER | read-only | 0x00000000

### Register Fields

#### RTC Control Register

Name: RTC_CR

Access: read-write

Address: 0x400E1460

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | - | - | - | - | - | CALEVSEL
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | - | - | - | - | - | TIMEVSEL
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | - | - | - | - | UPDCAL | UPDTIM

- UPDTIM: Update Request Time Register

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | Stops the RTC time counting.

- UPDCAL: Update Request Calendar Register

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | Stops the RTC calendar counting.

- TIMEVSEL: Time Event Selection

  Value | Name | Description
  --- | --- | ---
  0x0 | MINUTE | Minute change
  0x1 | HOUR | Hour change
  0x2 | MIDNIGHT | Every day at midnight
  0x3 | NOON | Every day at noon

- CALEVSEL: Calendar Event Selection

  Value | Name | Description
  --- | --- | ---
  0x0 | WEEK | Week change (every Monday at time 00:00:00)
  0x1 | MONTH | Month change (every 01 of each month at time 00:00:00)
  0x2 | YEAR | Year change (every January 1 at time 00:00:00)

#### RTC Mode Register

Name: RTC_MR

Access: read-write

Address: 0x400E1464

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | TPERIOD | - | THIGH
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | OUT1 | - | OUT0
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
HIGHPPM | CORRECTION
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | - | NEGPPM | - | - | PERSIAN | HRMOD

- HRMOD: 12-/24-hour Mode

  Value | Name | Description
  --- | --- | ---
  0 | - | 24-hour mode is selected.
  1 | - | 12-hour mode is selected.

- PERSIAN: PERSIAN Calendar

  Value | Name | Description
  --- | --- | ---
  0 | - | Gregorian Calendar.
  1 | - | Persian Calendar.

- NEGPPM: NEGative PPM Correction

  Value | Name | Description
  --- | --- | ---
  0 | - | positive correction (the divider will be slightly lower than 32768).
  1 | - | negative correction (the divider will be slightly higher than 32768).

- CORRECTION

  Value | Name | Description
  --- | --- | ---
  0 | - | No correction

- HIGHPPM: HIGH PPM Correction

  Value | Name | Description
  --- | --- | ---
  0 | - | lower range ppm correction with accurate correction.
  1 | - | higher range ppm correction with accurate correction.

- OUT0: RTCOUT0 Output Source Selection

  Value | Name | Description
  --- | --- | ---
  0x0 | NO_WAVE | no waveform, stuck at '0'
  0x1 | FREQ1HZ | 1 Hz square wave
  0x2 | FREQ32HZ | 32 Hz square wave
  0x3 | FREQ64HZ | 64 Hz square wave
  0x4 | FREQ512HZ | 512 Hz square wave
  0x5 | ALARM_TOGGLE | output toggles when alarm flag rises
  0x6 | ALARM_FLAG | output is a copy of the alarm flag
  0x7 | PROG_PULSE | duty cycle programmable pulse

- OUT1: RTCOUT1 Output Source Selection

  Value | Name | Description
  --- | --- | ---
  0x0 | NO_WAVE | no waveform, stuck at '0'
  0x1 | FREQ1HZ | 1 Hz square wave
  0x2 | FREQ32HZ | 32 Hz square wave
  0x3 | FREQ64HZ | 64 Hz square wave
  0x4 | FREQ512HZ | 512 Hz square wave
  0x5 | ALARM_TOGGLE | output toggles when alarm flag rises
  0x6 | ALARM_FLAG | output is a copy of the alarm flag
  0x7 | PROG_PULSE | duty cycle programmable pulse

- THIGH: High Duration of the Output Pulse

  Value | Name | Description
  --- | --- | ---
  0x0 | H_31MS | 31.2 ms
  0x1 | H_16MS | 15.6 ms
  0x2 | H_4MS | 3.91 ms
  0x3 | H_976US | 976 \xb5 s
  0x4 | H_488US | 488 \xb5 s
  0x5 | H_122US | 122 \xb5 s
  0x6 | H_30US | 30.5 \xb5 s
  0x7 | H_15US | 15.2 \xb5 s

- TPERIOD: Period of the Output Pulse

  Value | Name | Description
  --- | --- | ---
  0x0 | P_1S | 1 second
  0x1 | P_500MS | 500 ms
  0x2 | P_250MS | 250 ms
  0x3 | P_125MS | 125 ms

#### RTC Time Register

Name: RTC_TIMR

Access: read-write

Address: 0x400E1468

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | AMPM | HOUR
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | MIN
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | SEC

- SEC: Current Second

-

- MIN: Current Minute

-

- HOUR: Current Hour

-

- AMPM: Ante Meridiem Post Meridiem Indicator

  Value | Name | Description
  --- | --- | ---
  0 | - | AM.
  1 | - | PM.

#### RTC Calendar Register

Name: RTC_CALR

Access: read-write

Address: 0x400E146C

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | DATE
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
DAY | MONTH
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
YEAR
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | CENT

- CENT: Current Century

-

- YEAR: Current Year

-

- MONTH: Current Month

-

- DAY: Current Day in Current Week

-

- DATE: Current Day in Current Month

-

#### RTC Time Alarm Register

Name: RTC_TIMALR

Access: read-write

Address: 0x400E1470

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
HOUREN | AMPM | HOUR
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
MINEN | MIN
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
SECEN | SEC

- SEC: Second Alarm

-

- SECEN: Second Alarm Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | The second-matching alarm is disabled.
  1 | - | The second-matching alarm is enabled.

- MIN: Minute Alarm

-

- MINEN: Minute Alarm Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | The minute-matching alarm is disabled.
  1 | - | The minute-matching alarm is enabled.

- HOUR: Hour Alarm

-

- AMPM: AM/PM Indicator

-

- HOUREN: Hour Alarm Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | The hour-matching alarm is disabled.
  1 | - | The hour-matching alarm is enabled.

#### RTC Calendar Alarm Register

Name: RTC_CALALR

Access: read-write

Address: 0x400E1474

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
DATEEN | - | DATE
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
MTHEN | - | - | MONTH
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | - | - | - | - | - | - | -
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | - | - | - | - | - | -

- MONTH: Month Alarm

-

- MTHEN: Month Alarm Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | The month-matching alarm is disabled.
  1 | - | The month-matching alarm is enabled.

- DATE: Date Alarm

-

- DATEEN: Date Alarm Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | The date-matching alarm is disabled.
  1 | - | The date-matching alarm is enabled.

#### RTC Status Register

Name: RTC_SR

Access: read-only

Address: 0x400E1478

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | - | - | - | - | - | - | -
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | - | - | - | - | - | - | -
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | TDERR | CALEV | TIMEV | SEC | ALARM | ACKUPD

- ACKUPD: Acknowledge for Update

  Value | Name | Description
  --- | --- | ---
  0 | FREERUN | Time and calendar registers cannot be updated.
  1 | UPDATE | Time and calendar registers can be updated.

- ALARM: Alarm Flag

  Value | Name | Description
  --- | --- | ---
  0 | NO_ALARMEVENT | No alarm matching condition occurred.
  1 | ALARMEVENT | An alarm matching condition has occurred.

- SEC: Second Event

  Value | Name | Description
  --- | --- | ---
  0 | NO_SECEVENT | No second event has occurred since the last clear.
  1 | SECEVENT | At least one second event has occurred since the last clear.

- TIMEV: Time Event

  Value | Name | Description
  --- | --- | ---
  0 | NO_TIMEVENT | No time event has occurred since the last clear.
  1 | TIMEVENT | At least one time event has occurred since the last clear.

- CALEV: Calendar Event

  Value | Name | Description
  --- | --- | ---
  0 | NO_CALEVENT | No calendar event has occurred since the last clear.
  1 | CALEVENT | At least one calendar event has occurred since the last clear.

- TDERR: Time and/or Date Free Running Error

  Value | Name | Description
  --- | --- | ---
  0 | CORRECT | The internal free running counters are carrying valid values since the last read of RTC_SR.
  1 | ERR_TIMEDATE | The internal free running counters have been corrupted (invalid date or time, non-BCD values) since the last read and/or they are still invalid.

#### RTC Status Clear Command Register

Name: RTC_SCCR

Access: write-only

Address: 0x400E147C

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | - | - | - | - | - | - | -
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | - | - | - | - | - | - | -
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | TDERRCLR | CALCLR | TIMCLR | SECCLR | ALRCLR | ACKCLR

- ACKCLR: Acknowledge Clear

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | Clears corresponding status flag in the Status Register (RTC_SR).

- ALRCLR: Alarm Clear

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | Clears corresponding status flag in the Status Register (RTC_SR).

- SECCLR: Second Clear

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | Clears corresponding status flag in the Status Register (RTC_SR).

- TIMCLR: Time Clear

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | Clears corresponding status flag in the Status Register (RTC_SR).

- CALCLR: Calendar Clear

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | Clears corresponding status flag in the Status Register (RTC_SR).

- TDERRCLR: Time and/or Date Free Running Error Clear

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | Clears corresponding status flag in the Status Register (RTC_SR).

#### RTC Interrupt Enable Register

Name: RTC_IER

Access: write-only

Address: 0x400E1480

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | - | - | - | - | - | - | -
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | - | - | - | - | - | - | -
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | TDERREN | CALEN | TIMEN | SECEN | ALREN | ACKEN

- ACKEN: Acknowledge Update Interrupt Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The acknowledge for update interrupt is enabled.

- ALREN: Alarm Interrupt Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The alarm interrupt is enabled.

- SECEN: Second Event Interrupt Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The second periodic interrupt is enabled.

- TIMEN: Time Event Interrupt Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The selected time event interrupt is enabled.

- CALEN: Calendar Event Interrupt Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.

- TDERREN: Time and/or Date Error Interrupt Enable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.

#### RTC Interrupt Disable Register

Name: RTC_IDR

Access: write-only

Address: 0x400E1484

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | - | - | - | - | - | - | -
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | - | - | - | - | - | - | -
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | TDERRDIS | CALDIS | TIMDIS | SECDIS | ALRDIS | ACKDIS

- ACKDIS: Acknowledge Update Interrupt Disable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The acknowledge for update interrupt is disabled.

- ALRDIS: Alarm Interrupt Disable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The alarm interrupt is disabled.

- SECDIS: Second Event Interrupt Disable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The second periodic interrupt is disabled.

- TIMDIS: Time Event Interrupt Disable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The selected time event interrupt is disabled.

- CALDIS: Calendar Event Interrupt Disable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.
  1 | - | The selected calendar event interrupt is disabled.

- TDERRDIS: Time and/or Date Error Interrupt Disable

  Value | Name | Description
  --- | --- | ---
  0 | - | No effect.

#### RTC Interrupt Mask Register

Name: RTC_IMR

Access: read-only

Address: 0x400E1488

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | - | - | - | - | - | - | -
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | - | - | - | - | - | - | -
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | - | CAL | TIM | SEC | ALR | ACK

- ACK: Acknowledge Update Interrupt Mask

  Value | Name | Description
  --- | --- | ---
  0 | - | The acknowledge for update interrupt is disabled.
  1 | - | The acknowledge for update interrupt is enabled.

- ALR: Alarm Interrupt Mask

  Value | Name | Description
  --- | --- | ---
  0 | - | The alarm interrupt is disabled.
  1 | - | The alarm interrupt is enabled.

- SEC: Second Event Interrupt Mask

  Value | Name | Description
  --- | --- | ---
  0 | - | The second periodic interrupt is disabled.
  1 | - | The second periodic interrupt is enabled.

- TIM: Time Event Interrupt Mask

  Value | Name | Description
  --- | --- | ---
  0 | - | The selected time event interrupt is disabled.
  1 | - | The selected time event interrupt is enabled.

- CAL: Calendar Event Interrupt Mask

  Value | Name | Description
  --- | --- | ---
  0 | - | The selected calendar event interrupt is disabled.
  1 | - | The selected calendar event interrupt is enabled.

#### RTC Valid Entry Register

Name: RTC_VER

Access: read-only

Address: 0x400E148C

31 | 30 | 29 | 28 | 27 | 26 | 25 | 24
- | - | - | - | - | - | - | -
23 | 22 | 21 | 20 | 19 | 18 | 17 | 16
- | - | - | - | - | - | - | -
15 | 14 | 13 | 12 | 11 | 10 | 9 | 8
- | - | - | - | - | - | - | -
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
- | - | - | - | NVCALALR | NVTIMALR | NVCAL | NVTIM

- NVTIM: Non-valid Time

  Value | Name | Description
  --- | --- | ---
  0 | - | No invalid data has been detected in RTC_TIMR (Time Register).
  1 | - | RTC_TIMR has contained invalid data since it was last programmed.

- NVCAL: Non-valid Calendar

  Value | Name | Description
  --- | --- | ---
  0 | - | No invalid data has been detected in RTC_CALR (Calendar Register).
  1 | - | RTC_CALR has contained invalid data since it was last programmed.

- NVTIMALR: Non-valid Time Alarm

  Value | Name | Description
  --- | --- | ---
  0 | - | No invalid data has been detected in RTC_TIMALR (Time Alarm Register).
  1 | - | RTC_TIMALR has contained invalid data since it was last programmed.

- NVCALALR: Non-valid Calendar Alarm

  Value | Name | Description
  --- | --- | ---
  0 | - | No invalid data has been detected in RTC_CALALR (Calendar Alarm Register).
  1 | - | RTC_CALALR has contained invalid data since it was last programmed.