Adding an RTC to the Webpal
Since
the Webpal didn't have a real time
clock, I decided to add one.
I chose a DS1302 RTC chip and wired it up using some of the IO pins of
the CPU that originally were used by the
Chrontel CH7001A chip for centering information. Since I wasn't using
TV output (and there isn't any support in the Linux port for this
anyway!), these pins were
available for other hacking purposes. I set up the bootstrap
loader to
power down the Chrontel CH7001A chip (tvoff=1)
and wired up the DS1302 on top of the Chrontel CH7001A chip as shown in
the photo to the right.
A 3V lithium battery is needed to supply backup power when
the Webpal is powered down. You can see the wire leaving
the photo on the left side going to the positive terminal of the
lithium battery. The negative terminal of the lithium
battery is connected to ground.
A supercap could be used instead of the lithium
battery, but that would require modification of the RTC driver to
enable
the trickle charger in the DS1302. Obviously, the trickle
charger shouldn't be enabled if you hook up a non-rechargable (and
possibly explodable when recharged) battery like a lithium cell!
I ordered the DS1302 and the 32.768 crystal from Digikey. Be sure the
crystal you order is one designed for 6pf loading, otherwise your RTC
will not be accurate.
A datasheet for the DS1302 can be found here.
The wiring for the DS1302 is as follows:
- PIN 1 (VCC2) connects to
R8 on the side farthest from
the Chrontel CH7001A. This is +5V.
- PIN 2 (X1) connects to
one side of the 32.768 khz crystal (6pf loading)
- PIN 3 (X2) connects to
the other side of the 32.768 khz crystal (6pf loading)
- PIN 4 (GND) connects to
C41 on the side closest to
the Chrontel CH7001A. This is a GND.
- PIN 5 (RST) connects to
R11 on the side closest to
the Chrontel CH7001A
- PIN 6 (IO) connects to
R10 on the side closest to
the Chrontel CH7001A
- PIN 7 (SCLK) connects to
R9 on the side closest to the
Chrontel CH7001A
- PIN 8 (VCC1) connects to
the + terminal of your 3V lithium battery
Driver
Included in the kernel diffs is a driver for this chip as wired
above. It is enabled in the kernel configuration program
using the Webpal Real Time Clock
Support option in the Character
devices section. It is accessed from Linux via /dev/rtc. Also,
the driver exports status information via
/proc/driver/rtc.
The driver is based on the rtc
driver for x86.
To access it from the command line, I use hwclock which
exists in newer versions of busybox.
Last updated: Feb 19 2004