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.

MSP430F5335: RTC_B Calibration and Possible Errors in User's Guide

Part Number: MSP430F5335
Other Parts Discussed in Thread: MSP430F5438A

I am working on adding temperature compensation and calibration support for the RTC_B peripheral on the MSP430F5335.  There are a couple of spots that I have questions about in the October 2016 revision of the Users's Guide:

1) 23.2.5 Real-Time Clock Calibration

In step 3 of the basic flow to calibrate the frequency and equation for the absolute error (ppm) is given as |10x6(Fmeasured - Frtcclk)/Frtcclk|.  I am wondering if the denominator of this equation should not be Fmeasured instead of Frtcclk???  Each adjustment will be made with respect to the actual frequency (Fmeasured), not the desired frequency.

2) 23.2.5 In the NOTE: Minimum Possible Calibration

The actual text in the note is as follows:

"The minimal calibration possible is -4 ppm or +8 ppm. For example, setting RTCCALS = 0
and RTCCAL = 0h would result in a -4 ppm decrease in frequency. Similarly, setting
RTCCALS = 1 and RTCCAL = 0h would result in a +8 ppm increase in frequency."

This appears to be incorrect to me.  If the RTCCAL value is 0h then I believe that the calibration feature is disabled and no frequency increase or decrease is made no matter what the value of RTCCALS is.  Is this not correct???

In addition, I think the minimum possible correction should be:

+4.34ppm when RTCCALS = 1 and RTCCALx = 1

and

-2.17 when RTCCALS = 0 and RTCCALx = 1

Is this not correct???  If not, then the equations for calculating RTCCALx are even more wrong!

Thanks

Greg Dunn

  • Hello Greg,

    For your first question, the equation in Step 3 is correct. The ideal or theoretical value here is F_RTCCLK, is the expected frequency of 512 Hz, 256 Hz, or 1 Hz. The measured or experimental value here is F_MEASURED. If you search online for "error equation", you'll find variations of the equation below that calculate the absolute error.

    percent error = [experimental value - theoretical value] / theoretical value x 100%

    For your second question, Section 22.2.4 mentions that the RTCCAL bits are used for adjusting the frequency. Keep in mind that calibration is available only in calendar mode. In counter mode (when RTCMODE = 0, not RTCCAL), the calibration logic is disabled.

    Hope this helps!

    Regards,

    James

    MSP Customer Applications
  • Hello James,

    I think I have convinced myself that my first question is correct in the user guide. Sorry about that.

    The second question still doesn't make sense. Keep in mind that I am using the MSP430F5335 which implements RTC_B. RTC_B does not have an RTCMODE register as far as I can tell and does not support counter mode. I am definitely using RTC_B as a clock calendar. I actually referred to section 23.2.5 for RTC_B, not 22.2.4 for RTC_A. The first NOTE at the end of section 23.2.5 is where I believe there is an error, actually the whole note appears to be incorrect as far as I know. I believe the note should be altered to read as follows to make it correct:

    1) The smallest positive calibration adjustment is +4.34 ppm and it would occur when RTCCALS=1 and RTCCALx=1.
    2) The smalest negative calibration adjustment is -2.17 ppm and it would occur when RTCCALS=0 and RTCCALx=1.
    3) If RTCCALx=0 then there is no calibration preformed no mater what value is in RTCCALS.

    Im I missing something here?

    Thanks,
    Greg Dunn
  • Hello Greg,

    Greg Dunn said:
    I think I have convinced myself that my first question is correct in the user guide. Sorry about that.

    No problem.

    Greg Dunn said:
    The second question still doesn't make sense. Keep in mind that I am using the MSP430F5335 which implements RTC_B. RTC_B does not have an RTCMODE register as far as I can tell and does not support counter mode. I am definitely using RTC_B as a clock calendar. I actually referred to section 23.2.5 for RTC_B, not 22.2.4 for RTC_A.

    You're exactly right. I mistakenly referred to the RTC_A section rather than RTC_B. Thanks for catching that!

    Greg Dunn said:
    The first NOTE at the end of section 23.2.5 is where I believe there is an error, actually the whole note appears to be incorrect as far as I know. I believe the note should be altered to read as follows to make it correct:

    1) The smallest positive calibration adjustment is +4.34 ppm and it would occur when RTCCALS=1 and RTCCALx=1.
    2) The smalest negative calibration adjustment is -2.17 ppm and it would occur when RTCCALS=0 and RTCCALx=1.
    3) If RTCCALx=0 then there is no calibration preformed no mater what value is in RTCCALS.

    I see what you're saying. After doing some digging, I don't think this NOTE should be included in the RTC_B section. It appears to have been copied from the RTC_A section, which has the correct NOTE. I found that devices with RTC_A like the MSP430F5438A have the RTC6 errata. This errata points out that the step size of the RTC frequency adjustment is =+8ppm/-4ppm, which is twice the size specified in the User's Guide. Thus, the NOTE is included in the RTC_A section to highlight this errata to readers. This errata does not exist in the MSP430F5335 devices, so the NOTE doesn't apply. I'll request that it gets removed.

    If you ever find anything else in our documentation, you can also submit it by clicking the "Submit Documentation Feedback" at the bottom of the page in the datasheet, user's guide, app note, etc.

    Regards,

    James

    MSP Customer Applications

  • James,

    I wanted to share a little more information that I have determined from my testing. I think part of the information in the first NOTE about the minimum possible calibration is accurate. I ran a test with various values stored in RTCCTL2. I had a frequency logging device connected to the RTCCLK output with RTCCTL3 set to 3 to generate a 1Hz pulse. With this test setup I was able to monitor the frequency of each RTCCLK pulse and capture each adjustment pulse. The nominal RTCCLK frequency was of course very close to 1Hz. Any required adjustment pulses were output at the top of each minute, starting at the top of the hour and one minute apart consecutively. It does look like the minimum number of adjustments is 2 as the NOTE indicates. In the table below, the number of adjusted pulses transmitted each hour is shown for different RTCCALS and RTCCALx settings:

    RTCCALS RTCCALx Number of adjusted pulses Freq of each Adjusted Pulse Effective ppm adjustment
    1 3 4 1.01587 4 x 4.34 = 17.36 ppm
    1 2 3 1.01587 3 x 4.34 = 13.02 ppm
    1 1 2 1.01587 2 x 4.34 = 8.68 ppm
    1 0 0 nominal 1.0 No Adjustment
    0 0 0 nominal 1.0 No Adjustment
    0 1 2 0.99225 2 * -2.17 = -4.34 ppm
    0 2 3 0.99225 3 * -2.17 = -6.51 ppm
    0 3 4 0.99225 4 * -2.17 = -8.68 ppm

    As the note specifies, it does looks like the minimum number of adjustments per hour is 2, or +8.68 ppm and -4.34 ppm. The error is in the RTCCALS and RTCCAL settings specified in the NOTE which give these adjustments. As long as RTCCALx is 0, there are no adjustments made. When RTCCALx is 1 then there are 2 adjustments made - up or down depending on the RTCCALS setting. I believe this also would also make the equations for calculating RTCCALx in 23.2.5 step 4 (a) and (b) slightly incorrect as well. I believe they would require an offset of 1 for the RTCCALx value as shown below:
    4.
    (a) RTCCALx = ((Absolute Error) / 2.17) - 1
    (b) RTCCALx = ((Absolute Error) / 4.34) - 1

    This would also make the examples incorrect - the calculated RTCCALx values should be 1 less than specified.

    Please review and let me know if these observations are correct. I sure looks to be the case from my test results.

    Thanks,
    Greg Dunn
  • James,

    The table didn't show up in a very readable fashion. If you can send me an email to greg.dunn@eagleresearchcorp.com I will send a more readable version to you directly.

    Thanks,
    Greg Dunn
  • RTCCALS RTCCALx Number of adjusted pulses Freq of each Adjusted Pulse (Hz) Effective ppm adjustment
    1 3 4 1.01587 4 x 4.34 = 17.36 ppm
    1 2 3 1.01587 3 x 4.34 = 13.02 ppm
    1 1 2 1.01587 2 x 4.34 = 8.68 ppm
    1 0 0 1 (nominal) No adjustment
    0 0 0 1 (nominal) No adjustment
    0 1 2 0.99225 2 x -2.17 = -4.34 ppm
    0 2 3 0.99225 3 x -2.17 = -6.51 ppm
    0 3 4 0.99225 4 x -2.17 = -8.68 ppm
  • Hello Greg,

    First, let me say thanks for the detailed post and data - very impressive!

    I've put your data into a table in the post above, but please feel free to edit it if I missed anything. For your reference, you can use more advanced features when posting by clicking the "Insert Code, Attach Files and more..." link at the bottom of the Reply window. There, I clicked the "Insert/Edit Table" button (shown below) and then pasted in the data.

    What you're saying here makes sense, and it took me quite some time to dig into this. I think I understand what's in the user's guide. I'll try to explain it concisely. Basically, the equations and description in Section 23.2.5 seem to be assuming there's already an initial setting (or that the minimal calibration has already been done).

    If you look at the end of the second paragraph in Section 23.2.5, it says that "each RTCCALx calibration bit causes either 256 LF crystal clock cycles to be added every 60 minutes or 512 LF crystal clock cycles to be subtracted every 60 minutes, giving a frequency adjustment of approximately -2 ppm or +4 ppm, respectively". Now, looking at the data in your table, let's assume we're calibrating AFTER the minimal calibration has been done (RTCCALS = 0 or 1, RTCCALx = 1). Thus, the quoted text matches what you tested - for every RTCCALx bit, -2 ppm (RTCCALS = 0) and +4 ppm (RTCCALS = 1). For RTCCALS = 1, when RTCCALx went from 2 to 3, the ppm adjustment went from 13.02 ppm to 17.36 ppm (~4 ppm). Does this make sense?

    I believe the same thing is assumed for the equations. When RTCCALS = 0 or 1 and RTCCALx > 1, the difference in absolute error plugged into these equations is what needs added to the existing RTCCALx bit(s). Does this make sense?

    I'm assuming that the quoted text and equations weren't changed since the NOTE was assumed to cover the minimal (initial) calibration, which means everything else is correct. Regardless, I'll update my internal feedback to see if we can make this more straightforward.

    Regards,

    James

    MSP Customer Applications

  • James,

    I understand what you are saying, but as you said, you sure have to dig into it to come up with your explanation. Its really pretty simple if were clearly explained. I definitely wouldn't have got it right without some detailed testing. I think I finally understand exactly how it works now and have confidence in my temperature compensation algorithm.

    Thank you very much for you help!
    Greg

**Attention** This is a public forum