5
\$\begingroup\$

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...

\$\endgroup\$
1
  • 1
    \$\begingroup\$ What is annoying about it? \$\endgroup\$
    – markrages
    Commented Aug 5, 2011 at 21:17

3 Answers 3

4
\$\begingroup\$

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.

\$\endgroup\$
4
\$\begingroup\$

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.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Timer A and the watch crystal is the best way for the msp430 to keep time \$\endgroup\$
    – jsolarski
    Commented Aug 5, 2011 at 22:21
1
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ 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... \$\endgroup\$ Commented Aug 5, 2011 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.