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.

EKTM4C123 - RTC showing unexpectedly large error

HI,

The RTC is showing a positive  error of 9 mins 38 seconds over a period of 12 hrs 10 min, Does this suggest that the crystal is defective? My initialization code is given below:

void  RTCCInit(void)

{

 if (!HibernateIsActive())

    {

HibernateEnableExpClk(SysCtlClockGet());

HibernateClockConfig(HIBERNATE_OSC_HIGHDRIVE);

HibernateRTCEnable();

    }

}

Subsequent to this I am setting the time and observing it overnight and the clock gains time as above. I am using time.h to convert between local time and unix time.

b) Let me know if the following calculations are correct:

The above error translates to 578 seconds in 43800 seconds, or 0.845 seconds in 64 seconds. Therefore  should I write (0x7fff+ (0.845*32768)) in the RTC trim register to correct this error?

 

Regards

 

  • Pardon - know nothing of this vendor's Hibernate nor RTC mechanism - yet the xtal & its load capacitors (usually) must be well chosen.
    Short, direct pcb traces into the LF oscillator pins - and correct power during the full hibernate duration - are standard requirements.
  • The hardware is standard TI Launchpad with Abracon 32.768Khz crystal and loading caps (24pf) as provided.
  • Seems that your external components are well chosen.
    Should the vendor not arrive quickly you may alter & experiment w/different values passed to the RTC trim register. (i.e. hard to "spoil" an (already) rotten egg...
  • Hello Nikhil,

    That is correct for trim. However this is a large drift. Can you remove the API

    HibernateClockConfig(HIBERNATE_OSC_HIGHDRIVE);

    from the code as I don't think that is required for the crystal.

    Regards
    Amit
  • Thanks Amit,
    I already experimented with
    HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE); I think it might be the same as leaving out the API altogether. However I will try once again.
    This is a deviation of around 1.3%. Normally watch crystals have an uncalibrated accuracy of better than 100ppm . I will try changing the XTAL and see if that works.
    Regards
    Nikhil
  • Hello Nikhil

    The particular crystal has been used a lot in internal testing and has resulted in good values w/o the need for trimming. I would not suspect the crystal at this point. May be a good idea would be to test the crystal output jitter on a scope (make sure that an active probe is used to avoid loading the crystal pin)

    Regards
    Amit
  • I had similar problem and I measured constant error of 1.2 %.

    If you express your measured error relatively, you will get something about 1.3 % - almost the same.

    The problem is in Hibernation RTC Trim register, which should have default value 0x7FFF, however in my case it had 0x2040. This faulty behavior is described in device (TM4C123) erratasheet.

    The solution is to explicitly set the Trim register, for example by calling driverlib function:

    HibernateRTCTrimSet(0x7FFF);
  • Hello Tomas

    Can you confirm that the condition as mentioned in the errata sheet was happening on your system?

    Regards
    Amit
  • Yes, I can confirm, that this happens on my system using TM4C123GH6PMI device. Now I made some experiments and I have found out interesting behavior.
    It looks like the HIB_RTCT_TRIM isn't initialized after reset (tried system reset and core reset while running CCS Debug session). I have set this register and value persisted until I re-powered the device.
    After re-powering the device the trim register value is 0x2040.
  • I had faced similar issues last year. RTC Trim has to be explicitly initialized at POR. However I didnot report this as this is mentioned in the device Errata.
    Regards
  • Hello Tomas,

    Can you erase the device flash, power cycle the board (make sure VBAT is also 0), then write 0x2040 to the HIBCTL register and check the value of the registers in hibernate module?

    I have not seen this behavior except under the conditions of the errata.

    Regards
    Amit
  • Hello, Amit.

    I have erased device using LM Flash Programmer (entire flash) and than power cycled the device.

    However I am not sure how to write (access) registers without programming flash. So I created new project only with infinite loop in main function and than started debugging. Tell me, if I should have done it another way.

    When I started debug session, the registers were as follows:

    • HIB_RTCC 0x00000000
    • HIB_RTCM0 0xFFFFFFFF
    • HIB_RTCLD 0x00000000
    • HIB_CTL 0x80002000
    • HIB_IM 0x00000000
    • HIB_RIS 0x00000000
    • HIB_MIS 0x00000000
    • HIB_IC 0x00000000
    • HIB_RTCT 0x00007FFF
    • HIB_RTCSS 0x00000000
    • HIB:DATA 0x0A080010

    After writing 0x80002040 into HIB_CTL (setting CLK32EN) following registers had changed this way:

    • HIB_RTCM0 0x80002040
    • HIB_RTCLD 0x80000040
    • HIB_RIS 0x00000010
    • HIB_IC 0x00000010
    • HIB_RTCT 0x00002040

    Hope this will help,
    Tomas

  • Hello Tomas

    Apologies. I misread the errata. The Errata mentions any of the two conditions, while I read it as both the conditions.

    Regards
    Amit