![Circuit Surgery POEGM45051 User Manual Download Page 5](http://html1.mh-extra.com/html/circuit-surgery/poegm45051/poegm45051_user-manual_2608085005.webp)
Page
5
of
6
The list of registers and their associated contents are displayed for a second time and then the current time
(or, more accurately, the time entered by the user) is displayed continuously, updating every second.
Escape back to the system prompt by using “Ctrl + Z”
This is a quick (and dirty!) way to check the functionality of the RTCC chip, and also serves as a starting point
for your own software.
“hwclock”
In order to be able to use the “
hwclock
” command, a driver will need to be installed. There is not a specific
driver for the MPC7941x chip, but the one for a different chip (the DS1307) is suitable.
From the command prompt, type:
sudo modprobe rtc-ds1307
sudo bash
(enters Bash as Root)
echo mcp7941x 0x6f > /sys/bus/i2c/devices/i2c-1/new_device
(for Rev.2 Pi’s) OR...
echo mcp7941x 0x6f > /sys/bus/i2c/devices/i2c-0/new_device
(for Rev.1 Pi’s)
exit
(Return to standard user)
Now you will be able to issue the command:
sudo hwclock -r
which will read the contents of the clock, which should correspond with the time entered at the first testing
stage, and:
sudo hwclock –w
which will write the system time to the RTCC. Now, repeat the “
hwclock -r
” command and this time you should
see that the output has changed to reflect the system time. The following steps allow the various modules to
be loaded, so that the RTCC is available at system boot. Type:
sudo nano /etc/modules
Add the following line:
rtc-ds1307
Save and close the file.
Now open /etc/rc.local for editing:
sudo nano /etc/rc.local
Immediately before the line – “
exit 0
” add the following lines:
echo mcp7941x 0x6f > /sys/class/i2c-dev/i2c-1/device/new_device
hwclock -s
These two lines will create the device on boot and then write the time from the RTCC to the system.
Your Pi is now set up with a hardware Real Time Clock and can tell the time regardless of whether it’s
connected to the internet or not!