Hardware Reference
In-Depth Information
The remaining connections are quite simple.
1.
Take pin 1 and pin 2 and connect them to your crystal. The crystal is not polarity-sensitive
so feel free to connect it however you want.
2.
Next up are the I2C bus lines. Take pin 5 and connect it to the Raspberry Pi's P1-03 GPIO
pin, and take pin 6 and connect it to the Raspberry Pi's P1-05 GPIO pin. It's best to do this
when the Raspberry Pi is off: you don't want to short out anything.
Because the dS1338Z-33 is a slave device (just like the shift register described in Chapter 4), you could
combine it and another i2C device or many i2C devices on the same bus.
Note
3.
Don't forget to install your lithium battery as well; otherwise, your RTC won't keep any time.
4.
Once the connections have been made, turn on your Raspberry Pi.
It's time to put the RTC to use, but where is it? I guess you have never had to think about how to use an RTC
before, because it has always just been there.
The Soft Side
Since you expected it to just work, I am guessing the first thing you did was search the dmesg output, only to be
disappointed that no RTC was found. Did you really expect it to just work? I sure did not. I am sure you remember
working with the i2c-tools in Chapter 4, but if you don't you can find all the details on using i2c-tools there. The first
thing I did was load the i2c-dev module manually with this command:
# modprobe i2c-dev
This will allow you to run an I2C bus scan. If you recall from Chapter 4 you can do that via this command:
# i2cdetect 0
Keep in mind that you may need to scan bus 1 or bus 0, just like you did in Chapter 4. You can see from
Figure 8-15 that I have found a device at address 0x68. Oddly enough I found no way to set an address for this slave
device. So it may be wise to plan around this slave device if you want to add more I2C slave devices.
Figure 8-15. RTC at 0 x 68
 
 
Search WWH ::




Custom Search