Jump to content

[Energia Library] MSP430 Real Time Clock

Recommended Posts

  • 2 months later...



I using the Lib to turn on/off some lights during the day appart from other activities such as getting temp.


I am using the internal oscillator and I configured RTCconfig.h (#define RTCUSEVLOCLOCK) and commented the first 3 def (WDT, Date and subSecond). I prefer not to sold the XTAL.


I am trying to "tune" the VLOFREQUENCY value to get a closer result but even after changing VLOFREQUENCY drastically I am getting same time drift, almost half a second per minute.


The last part of my RTCconfig.h is:


//RTCUSEVLOCLOCK - enables use of the builtin VLO clock instead of the crystal. Comment out for Crystal, Uncomment for VLO
//                 note that this option is meaningless if RTCUSEWDT is defined. If

#define VLOFREQUENCY 11070  //Actual frequency of the VLO. In theory should be 11999 for 12kHz clock, but tweak until you get something reasonably accurate.




I tried with VLOFREQUENCY 25 and later 12000 and I got same drift. It seems that VLOFREQUENCY is not being affected in my setup. I Have only one RTCconfig.h placed in my sketchbook\libraries dir, so I assume that Energia is using it ;)


Any hint how to tune the time drift ?



Many thanks in advance,




PS: Many thanks for the Library!

Link to post
Share on other sites

Unfortunately the VLO clock will never be very accurate. It is dependent on voltage, temperature, and the way you hold your mouth. It's advantage is that it has very low power consumption and keeps running in LPM3. With the VLO clock, this library should really be called an Approximate Time Clock. By trial and error you can tweak the count number in the config file, and I was able to get it accurate to within a couple of minutes per day, but I think that is the best to hope for.


Ideally when using the VLO you would have an intermittent means of checking in with another time source - eg you have a wireless link to an accurate clock, which you only check in with once per hour to conserve power.


Another option for a moderately accurate clock without soldering the crystal would be to use the DCO clock - it does vary depending on voltage & temp but does exhibit less drift than the VLO. You would need to slightly rewrite the clock configuration code of the library to do this, and the clock will stop in LPM3. It is probably also possible to periodically re-calibrate the VLO from the DCO.


Perhaps another alternative would be to use one of the external RTC modules with an inbuilt crystal.


Unfortunately if you do want good accuracy without external hardware, it means heating up your soldering iron and attaching the crystal. It isn't real hard - just needs a steady hand, and a magnifier helps too.



Sent from my iPad using Tapatalk

Link to post
Share on other sites

Many thanks for your quick reply!.


The library is working perfectly and I am checking MSP time against PC one. Right now, almost 10PM, time difference since 8:53 AM is 2 seconds...VLO is compensating itself ;).


I will let it run a couple of days to check trends. I will come back if I got something consistent.

Up to now, I have not worked with DCO and I am not a great C coder neither. So I am keeping with VLO but considering "expending" 2 pins por XTAL, heheh


Again, thank you for the library and also the time to support us.


Have a Merry Christmas



Link to post
Share on other sites
  • 2 weeks later...

this is not working with msp430F5529 Launchpad unable to compile



/Applications/Energia.app/Contents/Resources/Java/hardware/msp430/libraries/RTCplus/RTCplus.cpp: In member function 'void RealTimeClock::begin()':
/Applications/Energia.app/Contents/Resources/Java/hardware/msp430/libraries/RTCplus/RTCplus.cpp:58:5: error: 'BCSCTL1' was not declared in this scope
/Applications/Energia.app/Contents/Resources/Java/hardware/msp430/libraries/RTCplus/RTCplus.cpp:59:5: error: 'BCSCTL3' was not declared in this scope
/Applications/Energia.app/Contents/Resources/Java/hardware/msp430/libraries/RTCplus/RTCplus.cpp:59:16: error: 'LFXT1S_2' was not declared in this scope
Link to post
Share on other sites

No they will not work with the 5529, nor will they work with the fr5739 or stellaris/tiva, they are strictly for the msp430x2xxx family.


The f5529 has on board RTC, making a library like this unnecessary. When my 5529 arrives I may do a library to simplify accessing the on board RTC, but it will be pretty low on my priorities in the foreseeable future.



Sent from my iPad using Tapatalk

Link to post
Share on other sites
  • 1 year later...



I know this is an old post but how is two timers being used? and what is the advanage of using wdt timer for this, instead of timerA. 


Best regards,



Updated version of the library attached. Main changes are:

  • Configuration option allows the Watch-Dog Timer to be used for the RTC instead of TimerA. This also requires replacements for the functions in wiring.c. A side effect caused by limitations of the 430 hardware is that delay, millis and micros only have a resolution of 1.9mS.
  • Added helper functions to convert the hmsDMY time into UnixTime format, return day-of-week, etc.
  • Added an alarm class.
  • Improved documentation.


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...