This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Best way to have RTC in a system - whether it is MCU RTC?

Other Parts Discussed in Thread: MSP430FR6870, MSP430FR5857, CC2640, MSP430FR5726

Hi everybody!

I develop intellectual sensors and primitive controllers. My favorite MCU - MSP430FR57xx family. Now I need to add new features to my controller, RTC included.

I'm not used to a Real Time Clock and relevant issues. Equally I don't need a LPM in my devices. So my 1-st reaction to a task of adding a real time control - use the dedicated RTC chip.

Then I've read about RTC in FR68xx family. It has RTC_C, good. But has not Vbat pin, AFAIK. So, the only way to continue timekeeping after the main power is off - catch the event and enter LPM3.5 mode. All MCU remains powered from a battery (and drains 700 nA).

In such an approach I have to do:

  • use power switch to turn to a battery if VCC drops
  • watch VCC to catch event
  • enter LPM
  • after power restoring I have to exit LPM and begin the program (it may be from reset point)

And 700 nA.

Maybe it's stupid, but it seems a little bit complicated to study all the powerful possibilities of the LPM and on-board RTC of a MSP430FR6870 chip - just to use a very very simple functionality - have a real time clock.

On the contrary: I take an RTC (Abracon AB0805 has stunned me with 55 nA drain) and power it from the battery constantly. In our old devices we used DS1307 and it took several years to discharge CR2032. And:

  • no switch of power
  • no power monitoring
  • no LPM
  • no special starting procedures

And, as a bonus, I use MSP430FR5857 that has not RTC but satisfies all other demands.

What have I missed in my meditations?

Regards,

Yury

  • You don't need to manually switch power source. You can use two diodes to combine two power sources for MSP430. LPM3.5 is exactly what you need.

    Sure, an external RTC chip seems easier, but the total cost is usually higher.
  • I never said we need to switch power manually. But even 2 diodes are some elements. And they steal 0.4V, so needed in low-voltage applications.

    An external RTC is easier and it may be not higher in BOM, after all. Maybe an absence of Vbat pin on MCU is just a TI vanity line: our LPM3.5 is so powerful, we can sleep so quietly :)

  • The voltage drop of diodes depends on the current. For RTC mode, the current is too small to notice the voltage drop. Diodes are much cheaper than power switch mentioned by your first post.

    For mass production & material preparation consideration, I still prefer single MSP430 without external RTC chip. Less is better.

    Anyway, you already have choice in your mind, just follow your heart.

  • Robert Chen said:
    For RTC mode, the current is too small to notice the voltage drop

    I missed this point. So obvious, of course. Thanks!

    Maybe I don't notice something else. It would be great to look at a practical case.

    • What with the VCC value? Is it 3.3V or do you make it 3.6V to compensate diode voltage drop in an active mode?
    • Do you connect AVCC to DVCC or is it powered before diode switch?
    • How do you monitor power? Is it a dedicated ADC input, comparator or is there a solution without MCU pin usage? I need practically all my pins... And I don't use analog parts of MCU chip at all, so far.
    • If all I need is to have real time - is my choice is 100% an LMP3.5? The workflow after power cycle have to be exactly as in usual case with switching on an MCU: all RAM state must be ignored, all registers are in their default state. Only time is running. 
    • Have you ever faced a problem with standard quartz generation on TI MCUs? I had several boards that did not generate properly, seldom as it was. Though the layout was quite sensible, as it seemed. And I decided to use an integrated generator. That is an additional cost and I dislike my choice - but I need a reliability. Now I think about the same circuitry with LF quartz and - will not I have the problems too?  

    Robert Chen said:
    Anyway, you already have choice in your mind

    As you see, I'm just uncertain. I appreciate your help very much.

    Regards,

    Yury

  • . MSP430 can run from 1.8V to 3.6V. So, it will still run well when the voltage drops from 3.3V to even 2.9V. This mean you don't need to raise the voltage of main power supply.

    . In my use cases, I use analog part of MSP430 so that AVCC is always connected. I don't know if AVCC is still required for RTC mode (have to check data sheet). But, I think you can leave it connected since the power consumption is still very low (about 1uA).

    . Since you don't use analog yet, you can use ADC to check main power voltage periodically. But you can also check the SVS functionality of MSP430. SVS can be used to monitor voltage and generate an interrupt when the voltage is below certain level. For myself, I use another approach to detect voltage as described in my blog: www.rcfocus.tw/.../new-approach-to-implement-msp430_20.html. But this method will occupy one I/O pin.

    . You can simply use LPM3 to solve your problem, but the current consumption is a little higher than LPM3.5.

    a) For LPM3, you don't even need to use RTC module, you can use watchdog timer as RTC counter. Sure, you can use RTC module and keep watchdog as it should be. You can check main power voltage by using ADC periodically at low frequency. This is an issue for this method, if the voltage different between main power and battery is not big enough, you will have no way to distinguish which one is powering MSP430. So, you have to either raise the main power voltage or decrease the battery voltage. Another solution is to use a dedicated I/O pin connected to main power.

    b) For LPMx.5, the only thing you have to do is to "unlock I/O" when waked up. But, how to "wake up" the system when main power is back. A simple way is to use an I/O pin connected to main power and configure this pin as the source to wakeup system. When CPU is waked up, you can unlock I/O in main() and continue the normal program flow.

    . One important thing you have to take care when using crystal is the "load capacitance compensation". Usually you will see two small capacitors around the crystal. If the effective capacitance (CL) is wrong then the crystal won't get oscillated. For MSP430, you can use internal CL to compensate without using external capacitors. I always use 7pF crystal because 7pF is inside the supported range of MSP430. So, I don't need to place two physical capacitors but I have to enable the internal compensation in main(). I also use the same crystal in CC2640, so I have to add two external capacitors since CC2640 doesn't support internal CL compensation.

    *** If you use external capacitors then you have to take care of the CL calculation. We need to calculate the "effective" capacitance and the layout trace induced capacitance. Here is my equation for your reference:
    C = 2*(CL - [2~5]pF)
    where [2~5] is the capacitance induced by trace. For example, if the crystal is marked as 7pF load-capacitance then
    C = 2*(7-[2~5]) = 10~4pF
    You have to place two 4~10pF capacitors. Yes, 6.8pF seems a good choice, very close to 7pF. But if the crystal is marked as 15pF then
    C = 2*(15-[2~5]) = 26~20pF
    So, 22pF is the correct choice. But some inexperienced engineers use capacitors with the same capacitance (i.e. 15pF) listed in crystal's data sheet and cause a lot of stability issue.

    *** If you solder the crystals manually, please make sure you have clear the soldering flux very very carefully. The flux will affect the capacitance and cause issue.

    You can also verify the final frequency by using a "counter" with 8 digits. For 32.768KHz crystal, you can adjust the compensation capacitors to get 32767.999 ~ 32768.001. But remember, you can NOT probe the crystal pinout directly. You can let ACLK output at certain I/O pin and probe that pin.

    In my experiences, you will get rid of the crystal stability issue if you follow the above suggestion.
  • Robert,

    Your answer is so profound that I need some time to understand it. Thank you very much!

    Regards,

    Yury

  • Robert Chen said:
    For MSP430, you can use internal CL to compensate without using external capacitors

    Can you give a name of this feature? I can not find it in fr5726 or fr58xx families. The only things dependent on quartz are HFXTDRIVE / LFXTDRIVE and HFFREQ in CSCTL4 register (for fr58/59/68/69). I tried various strength with my msp430fr5726 chip: if the chip did not want to generate - it wouldn't. I tried to use capacitors from 5.6 to 30 pF... No stable result.

    I accept a possibility that it was my fault with init procedures, of course. But at that time I took an external clock and dropped the issue.

    Now your help gave me a new drive to understand why world-broad circuitry does not work in my boards.

  • XIN & XOUT pins are set to GPIO mode by default. Do you set it to XT1 mode by setting PxSEL?

    Probably not every MSP430 support internal compensation, I have to check FR5726 data sheet.

  • Robert Chen said:
    Do you set it to XT1 mode by setting PxSEL?

    Yes, Sir!

    Besides, if I wouldn't - no single chip generated. But most of chips worked OK.

    Robert Chen said:
    I have to check FR5726 data sheet.

    No need!  If you help me to find it in 58/59 series. I'll check 5726 myself and tell you the result.

  • I try to understand your method of VCC monitoring (your blog). Have you realised your idea in practice or is it only theoretical construction?

    The overall idea is OK, but I cannot get how the Vref and VCC are used simultaneously. We need Vref to V- terminal and we need VCC (through resistor ladder) at V+ terminal. But, according to the Figure 29-1. Comparator_E Block Diagram only one terminal is chosen by CERSEL bit.

    Next. The output of  Reference Generator is either Vref or VCC, not both.

    And the last. About the P1.1 pin. If we set P1SEL0.1 = P1SEL1.1 = 1, the pin is an analog mode. OK! But Table 29-2. CECTL0 Register Description says that if CEIMEN = 1 "The internal reference voltage is disabled for this channel." I don't understand what does it mean.

  • Sure, all my blogs are real case used in real projects, not just "idea".

    You should also look at Figure 29-4 then you will understand how it can work. 

    In Figure 29-1, there is two "switch" symbols on the two multiplexers selected by CEIMSEL & CEIPSEL. I guess the two "switches" are CEIMEN and CEIPEN. When you select an analog channel by CEIPSEL, it doesn't mean the signal path is "connected" to comparator. CEIMEN and CEIPEN are used to connect them.

  • Robert Chen said:
    Sure, all my blogs are real case used in real projects, not just "idea"

    It might be any way. Sometimes a pure idea is useful too.

    OK, I begin to understand the implementation of your idea. The best of it is the use of inner ladder to scale VCC: it eliminates external resistors and it may be switched off.

    May I propose a minor change? I'd use CEREF0_15 instead of CEREF0_16. It allows a hysteresis of ab. 0.14V (scaled to VCC) and costs nothing. When VCC drops and approaches 2.26V, there will not be a comparator output oscillation. I think the oscillation drains power (till comparator is checked and comparator switched off).

    BTW, I'd like to ask you about that CL compensation feature we spoke of - can you call it, as it's named in manuals?

    Regards,

    Yury