# What would be the best way to design a real time clock for the MSP430?

Basically that. The way I am doing it now is with the TimerA set to 1 second interrupts. But I think that it's very annoying. Are there any other ways to do it?

I want to basically set timers on that clock, like, shutdown until 40 seconds have passed...

• What is annoying about it? – markrages Aug 5 '11 at 21:17

## 3 Answers

It's not perfectly clear to whether you want a real-time clock or a stopwatch (the 40 seconds you mention).

You could use an RTC IC (Real-Time Clock), like the NXP PCF8563. This one is available in several packages, including both the old DIL and a very small DFN.
But you probably don't need a separate RTC IC. It's typically used because it consumes very little power, and the rest of the circuit can power down while the RTC keeps running of a battery or supercap. The MSP430, however, is also a low-power device, and it has a low-frequency oscillator which can run on the same 32.768kHz crystal you would use for the RTC.
In one project I had the MSP430 running continuously on a 32kHz crystal, and yet it consumed less than 5$\mu$A. That's more than an RTC (the PCF8563 only needs 250nA), but it will be acceptable for many applications.

What's your problem with the 1s interrupt? If you want to make a real-time clock you'll need a time-cue anyhow, whether generated internally or coming from an external RTC. Upon interrupt you can perform required updates of seconds, minutes and hour counters, and wait for the next interrupt. You even could work with 10ths of a second, although with the 32.768kHz this will have a minor deviation. You would have four tenths of a second or 3277 clock ticks, followed by one tenth of 3278 ticks, to get exactly 1/2 second, so repeat this pattern a second time to complete one second.

There are MSP430 devices with a low-power oscillator that use a standard 32.768 kHz watch crystal and are intended specifically for that sort of application. A typical one is the MSP430F1101.

• Timer A and the watch crystal is the best way for the msp430 to keep time – jsolarski Aug 5 '11 at 22:21

Usually a real-time clock is done by either having a real-time clock module built in to the microcontroller, or to use an external real-time clock module such as the DS1305 from Maxim.

These can typically be programmed to trigger an interrupt at a pre-defined time, and run off their own 32.768KHz crystal. They often have their own battery-backup circuit, and some even contain charge circuits too.

• That would be great, but I have an already developed platform, mainly a zolertia z1, which does not have any kind of realtime module. I can only rely on the microcontrollers clocks... – Sergio Campamá Aug 5 '11 at 20:39