Rabbit 4000 Microprocessor
User's Manual
PREV INDEX NEXT


4. System Management

4.1 Overview

There are a number of basic system peripherals in the Rabbit 4000 processor, some of which are covered in later chapters. The peripherals covered in this chapter are the periodic interrupt, the real-time clock, the watchdog timers, the battery-backed onchip-encryption RAM, and some of the miscellaneous output pins and their control and processor registers that provide the processor ID and revision numbers.

The periodic interrupt, when enabled, is generated every 16 clocks of the 32 kHz clock (every 488 µs, or 2.048 kHz). This interrupt can be used to perform periodic tasks.

The real-time clock (RTC) consists of a 48-bit counter that is clocked by the 32 kHz clock. It is powered by the VBAT pin, and so can be battery-backed. The value in the counter is not affected by reset, and can only be set to zero by writing to the RTC control register. The 48-bit width provides a 272-year span before rollover occurs.

There are two watchdog timers in the Rabbit 4000, both clocked by the 32 kHz clock. The main watchdog timer can be set to time out from 250 ms to 2 seconds, and resets the processor if not reloaded within that time. Its purpose is to restart the processor when it detects that a program gets stuck or disabled.

The secondary watchdog timer can time out from 30.5 µs up to 7.8 ms, and generates a Priority 3 secondary watchdog interrupt when it is not reset within that time. The primary use for the secondary watchdog is to act as a safety net for the periodic interrupt — if the secondary watchdog is reloaded in the periodic interrupt, it will count down to zero if the periodic interrupt stops occurring. In addition, it can be used as a periodic interrupt on its own.

The battery-backed onchip-encryption RAM consists of 32 bytes of memory that are powered by the VBAT pin. Their values are not affected by reset, but are erased if the state of the SMODE pins changes. These 32 bytes are intended for storing sensitive data (such as an encryption key) somewhere other than an external memory device. The "tamper-protection" erase feature prevents loading a program into the onchip-encryption RAM via the programming port and reading out the bytes.

The following other registers are also described in this chapter.

4.1.1 Block Diagram


4.1.2 Registers

Register Name Mnemonic I/O Address R/W Reset
Global Control/Status Register
GCSR
0x0000
R/W
11000000
Real-Time Clock Control Register
RTCCR
0x0001
W
00000000
Real-Time Clock Byte 0 Register
RTC0R
0x0002
R/W
xxxxxxxx
Real-Time Clock Byte 1 Register
RTC1R
0x0003
R
xxxxxxxx
Real-Time Clock Byte 2 Register
RTC2R
0x0004
R
xxxxxxxx
Real-Time Clock Byte 3 Register
RTC3R
0x0005
R
xxxxxxxx
Real-Time Clock Byte 4 Register
RTC4R
0x0006
R
xxxxxxxx
Real-Time Clock Byte 5 Register
RTC5R
0x0007
R
xxxxxxxx
Watchdog Timer Control Register
WDTCR
0x0008
W
00000000
Watchdog Timer Test Register
WDTTR
0x0009
W
00000000
Secondary Watchdog Timer Register
SWDTR
0x000C
W
11111111
Global Output Control Register
GOCR
0x000E
R/W
00000000
Global CPU Configuration Register
GCPU
0x002E
R
0xx00010
Global Revision Register
GREV
0x002F
R
0xx00000
Battery-Backed Onchip-Encryption RAM Byte 00–1F
VRAM00–VRAM1F
0x0600–0x061F
R/W
xxxxxxxx


4.2 Dependencies

4.2.1 I/O Pins

The CLK, STATUS, /WDTOUT, and /BUFEN pins are controlled by GOCR. Each of these pins can be used as general-purpose outputs by driving them high or low:

The values in the battery-backed onchip-encryption RAM bytes are cleared If the signal on the SMODE pins changes state.

4.2.2 Clocks

The periodic interrupt, real-time clock, watchdog timer, and secondary watchdog timer require the 32 kHz clock.

4.2.3 Interrupts

The periodic interrupt is enabled in GCSR, and will occur every 488 µs. It is cleared by reading GCSR. It can operate at Priority 1, 2, or 3.

The secondary watchdog interrupt will occur whenever the secondary watchdog is enabled and allowed to count down to zero. It is cleared by restarting the secondary watchdog by writing to WDTCR. The secondary watchdog interrupt always occurs at Priority 3.

4.3 Operation

4.3.1 Periodic Interrupt

The following steps explain how a periodic interrupt is used.

  1. Write the vector to the interrupt service routine to the internal interrupt table.

  2. Enable the periodic interrupt by writing to GCSR.

  3. The interrupt request is cleared by reading from GCSR.

A sample interrupt handler is shown below.

4.3.2 Real-Time Clock

The real-time clock consists of six 8-bit registers that together comprise a 48-bit value. The real-time clock is not synchronized to the read operation, so the least-significant bit should be read twice and checked for matching values; if the two reads do not match, then the real-time clock may have been updating during the read and should be read again.

Writing to RTC0R latches the current real-time clock value into the RTCxR holding registers, so the following sequence should be used to read the real-time clock.

  1. Write any value to RTC0R and then read back a value from RTC0R.

  2. Write a value to RTC0R again, and again read back a value from RTC0R.

  3. If the two values do not match, repeat Step 2 until the last two readings are identical.

  4. At this point, registers RTC1R through RTC6R can also be read and used.

Note that the periodic interrupt and the real-time clock are clocked by the same edge of the 32 kHz clock; if read from the periodic interrupt, the count is guaranteed to be stable and only needs to be read once (assuming it occurs within one clock of the 32 kHz clock).

The real-time clock can be reset by writing the sequence 0x40 – 0x80 to RTCCR. It can be reset and left in the byte increment mode by writing 0x40 – 0xC0 to RTCCR and then writing bytes repeatedly to RTCCR to increment the appropriate bytes of the real-time clock. The byte increment mode is disabled by writing 0x00 to RTCCR.

4.3.3 Watchdog Timer

The watchdog timer is enabled on reset with a 2-second timeout. Unless specific data are written to WDTCR before that time expires, the processor will be reset. The watchdog timer can be disabled by writing a sequence of two bytes to WDTTR as described in the register description.

Table 4-1. Watchdog Timer Settings

WDTCR Value

Effect

0x5A
Restart watchdog timer with 2-second timeout.
0x57
Restart watchdog timer with 1-second timeout.
0x59
Restart watchdog timer with 500-millisecond timeout.
0x53
Restart watchdog timer with 250-millisecond timeout.
0x5F
Restart the secondary watchdog timer.


The watchdog timer also contains a special test mode that speeds up the timeout period by clocking it with the peripheral clock instead of the 32 kHz clock. This mode can be enabled by writing to WDTTR.

4.3.4 Secondary Watchdog Timer

The secondary watchdog timer is disabled on reset, unless the reset occurs because the primary watchdog timer times out while the secondary watchdog timer is enabled. The BIOS provided by Rabbit Semiconductor in Dynamic C avoids this bug by disabling the secondary watchdog on startup or reset by writing 0x5F to WDTCR. The following steps explain how to use the secondary watchdog timer.

  1. Write the vector to the interrupt service routine to the internal interrupt table.

  2. Write the desired timeout period to SWDTR. This also enables the secondary watchdog timer.

  3. Restart the secondary watchdog timer by either writing the timeout period to SWDTR or writing 0x5F to WDTCR.

If the secondary watchdog timer counts down to zero, a Priority 3 secondary watchdog interrupt will occur. This interrupt request is cleared by writing a new timeout value to SWDTR. A sample interrupt handler is shown below.

4.4 Register Descriptions

Global Control/Status Register (GCSR) (Address = 0x0000)

Bit(s)

Value

Description

7:6
00
No reset or watchdog timer timeout since the last read.
(rd-only)
01
The watchdog timer timed out. These bits are cleared by a read of this register.
10
This bit combination is not possible.
11
Reset occurred. These bits are cleared by a read of this register.
5
0
No effect on the periodic interrupt. This bit will always be read as zero.
1
Force a periodic interrupt to be pending.
4:2
000
Processor clock from the main clock, divided by eight.
Peripheral clock from the main clock, divided by eight.
001
Processor clock from the main clock, divided by eight.
Peripheral clock from the main clock.
010
Processor clock from the main clock.
Peripheral clock from the main clock.
011
Processor clock from the main clock, divided by two.
Peripheral clock from the main clock, divided by two.
100
Processor clock from the 32 kHz clock, optionally divided via GPSCR.
Peripheral clock from the 32 kHz clock, optionally divided via GPSCR.
101
Processor clock from the 32 kHz clock, optionally divided via GPSCR.
Peripheral clock from the 32 kHz clock, optionally divided via GPSCR.
The main clock is disabled.
110
Processor clock from the main clock, divided by four.
Peripheral clock from the main clock, divided by four.
111
Processor clock from the main clock, divided by six.
Peripheral clock from the main clock, divided by six.
1:0
00
Periodic interrupts are disabled.
01
Periodic interrupts use Interrupt Priority 1.
10
Periodic interrupts use Interrupt Priority 2.
11
Periodic interrupts use Interrupt Priority 3.


Real-Time Clock Control Register (RTCCR) (Address = 0x0001)

Bit(s)

Value

Description

7:0
0x00
No effect on the real-time clock counter, or disable the byte increment function, or cancel the real-time clock reset command.
0x40
Arm the real-time clock for reset or byte increment. This command must be written prior to either the real-time clock reset command or the first byte increment write.
0x80
Reset all six bytes of the real-time clock counter to 0x00. The reset must be preceded by writing 0x40 to arm the reset function.
0xC0
Reset all six bytes of the real-time clock counter to 0x00, and remain in byte-increment mode in preparation for setting the time.
7:6
01
This bit combination must be used with every byte-increment write.
5:0
0
No effect on the real-time clock counter.
1
Increment the corresponding byte of the real-time clock counter.


Real-Time Clock x Register (RTC0R) (Address = 0x0002)
(RTC1R) (Address = 0x0003)
(RTC2R) (Address = 0x0004)
(RTC3R) (Address = 0x0005)
(RTC4R) (Address = 0x0006)
(RTC5R) (Address = 0x0007

Bit(s)

Value

Description

7:0
Read
The current value of the 48-bit real-time clock counter is returned.
Write
Writing to the RTC0R transfers the current count of the real-time clock to a holding register while the real-time clock continues counting.


Watchdog Timer Control Register (WDTCR) (Address = 0x0008)

Bit(s)

Value

Description

7:0
0x5A
Restart the watchdog timer with a 2-second timeout period.
0x57
Restart the watchdog timer with a 1-second timeout period.
0x59
Restart the watchdog timer with a 500 ms timeout period.
0x53
Restart the watchdog timer with a 250 ms timeout period.
0x5F
Restart the secondary watchdog timer.
other
No effect on watchdog timer or secondary watchdog timer.


Watchdog Timer Test Register (WDTTR) (Address = 0x0009)

Bit(s)

Value

Description

7:0
0x51
Clock the least significant byte of the watchdog timer from the peripheral clock.
0x52
Clock the most significant byte of the watchdog timer from the peripheral clock.
0x53
Clock both bytes of the watchdog timer, in parallel, from the peripheral clock.
0x54
Disable the watchdog timer. This value, by itself, does not disable the watchdog timer. Only a sequence of two writes, where the first write is 0x51, 0x52, or 0x53, followed by a write of 0x54, actually disables the watchdog timer. The watchdog timer will be re-enabled by any other write to this register.
other
Normal clocking (32 kHz clock) for the watchdog timer.


Secondary Watchdog Timer Register (SWDTR) (Address = 0x000C)

Bit(s)

Value

Description

7:0
The time constant for the secondary watchdog timer is stored. This time constant will take effect the next time that the secondary watchdog counter counts down to zero. The timer counts modulo n + 1, where n is the programmed time constant. The secondary watchdog timer can be disabled by writing the sequence 0x5A – 0x52 – 0x44 to this register.


Global Output Control Register (GOCR) (Address = 0x000E)

Bit(s)

Value

Description

7:6
00
CLK pin is driven with peripheral clock.
01
CLK pin is driven with peripheral clock divided by 2.
10
CLK pin is low.
11
CLK pin is high.
5:4
00
STATUS pin is active (low) during a first opcode byte fetch.
01
STATUS pin is active (low) during an interrupt acknowledge.
10
STATUS pin is low.
11
STATUS pin is high.
3:2
00
/WDTOUT pin functions normally.
01
Enable /WDTOUT for test mode. Rabbit Semiconductor internal use only.
10
/WDTOUT pin is low (1 cycle min, 2 cycles max, of 32 kHz).
11
This bit combination is reserved and should not be used.
1:0
00
/BUFEN pin is active (low) during external I/O cycles.
01
/BUFEN pin is active (low) during data memory accesses.
10
/BUFEN pin is low.
11
/BUFEN pin is high.


Global CPU Register (GCPU) (Address = 0x002E)

Bit(s)

Value

Description

7
0
Program fetch as a function of the SMODE pins.
(read only)
1
Ignore the SMODE pins program fetch function.
6:5
read
These bits report the state of the SMODE pins.
4:0
00010
CPU identifier for this version of the chip.


Global Revision Register (GREV) (Address = 0x002F)

Bit(s)

Value

Description

7
0
Program fetch as a function of the SMODE pins.
(read only)
1
Ignore the SMODE pins program fetch function.
6:5
read
These bits report the state of the SMODE pins.
4:0
00000
Revision identifier for this version of the chip.


Battery-Backed Onchip-Encryption RAM (VRAM00) (Address = 0x0600)
through through
(VRAM1F) (Address = 0x061F)

Bit(s)

Value

Description

7:0
General-purpose RAM locations. Cleared by Intrusion Detect conditions.



Rabbit Semiconductor
www.rabbit.com
PREV INDEX NEXT