[Nov 2010] initial write-up
[May 17, 2013] adjust source code for newer mspgcc. now source in github, link at bottom
[May 20, 2013] add setup instruction video
this is a enhanced version of the 3p4w clock project. having finished the 3p4w clock, the 3p4w clock project started out as a excercise to do "something" with the new ti value series MCUs. in practice the 3p4w clock was not accurate for normal day to day use. with these enhancements i made an attempt to make it usable to keep it on my bedside table. i.e. waking me up and not late for work.
basically i am adding a cheap rtc timing keeping chip to the original design. i do not consider this an elegant solution as it requires additional parts. my origianl goal on the 3p4w clock project was to build a working led clock w/ minimal components. with the limited io pins on the 14 pin msp430g2211/2231 devices, it is just not possible to do that. accurate time can only be kept with the use of external crystal, but this will take away precious io pins that is neccessary to drive the 4 x 7 segment led display. may be when ti starts shipping 20 pin value line dip devices i can make use of it to make a better clock.
having said that, adding the rtc chip do have some benefits. the project still stays on one single mini breadboard. i can now have date and day of week function. the clock can now go into lpm4 deep sleep for further power saving.
there is no special design features here, the led driving mechanism (and how i drive the led module w/ minimal pin counts) are described in the 3p4w clock page. worth mentioning is that i am using i2c to talk to the rtc chip. i have to use software i2c over the msp430 builtin. all the available io pins are connected to the led module and the particular 2 pins need to do hardware i2c (P1.6, P1.7) is connected as cathode + anode for the led display. i had to pick 2 io pins that do not interfere w/ each other. i.e. they must be both anode or both cathode on the led display. that's the reason i have to use software i2c.
the mcu fetches time information from the rtc chip at the zero second of every minute and sychronize it's registers. i have to initailize the corresponding port io pins whenever this happens, as the io pins are shared between led multiplexing and i2c (and button press, and pin interrupt,...)
when the mcu goes into non-displaying power saving mode, the mcu switches the button pin from input (polling) to pin interrupt, commands the rtc (via i2c) to generate hardware interrupt upon alarm event, and goes into lpm4 deep sleep. in lpm4, all clocks in the mcu are turned off and the project only wakes up when receving a button press interrupt or a alarm interrupt from the rtc.
i measured 2-6mA current when the clock is active (depending on the led dimmer/brightness level) and when sleep it's 70ua, i don't know how it uses so much, from the datasheets of both mcu and rtc chip i should be getting 2-3ua when sleep. i guess i am not setting up the mcu ports properly before going to sleep. anyway it is not bothering me and i leave it as it. 2 x AAA batteries will typically give you 1200 mAH, so i figure if i had the clock active 8 hours a day, i will need to replace the batteries like every month, more or less. of course if u do not turn it on during all day it will run much longer. and you always has the option to supply power via a power adapter.
i had also taken out the temperature display function due to code space. i could make an effort to have it included but it's something i don't need. this way i can also use the msp430g2211 chip and save the 2231 for other projects. the project rings in at around 1950 bytes when build with mspgcc, may be iar can do better.
the LED display is commonly available in ebay, look for those 0.4" or 0.36" 4 digit displays, you will want to make sure it's common cathode and the pin layout matches (most do)
the rtc chip can also be sourced from ebay, i choose the pcf8563 over the more popular ds130x only because they are cheaper and readily from ebay, the basics are the same, you can easily change the code to talk to some other devices
latest code now on github