Electronic – What would be the best way to design a real time clock for the MSP430

clockinterruptsmsp430timer

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…

Best Answer

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.