MIMXRT1061C RTC accuracy with external chrystal

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MIMXRT1061C RTC accuracy with external chrystal

388 Views
JLa63
Contributor III

Hi,

We are using MIMXRT1061C MCU in our device with external 32.768 kHz crystal connected.

However it seems that RTC is ticking too fast, about 10 seconds in 18 hours at room temperature.

Related registers should be correctly set:
XTALOSC24M_MISC0 0x24008080
CCM_ANALOG_MISC0 0x24008080

Do anybody have any idea, what could be wrong? Our other devices with same external crystal used have perfectly accurate RTC.

RTC initialization is done the following way:

snvs_lp_srtc_config_t snvsSrtcConfig= {false, 0};
snvs_hp_rtc_config_t snvsRtcConfig = {false, 0U, 0U};

SNVS_HP_RTC_Init(SNVS, &snvsRtcConfig);
SNVS_LP_SRTC_Init(SNVS, &snvsSrtcConfig);

NVIC_ClearPendingIRQ(SNVS_HP_WRAPPER_IRQn);
DisableIRQ(SNVS_HP_WRAPPER_IRQn);
GPC_DisableIRQ(GPC, SNVS_HP_WRAPPER_IRQn);

bool lpsrtcEnabled = (SNVS->LPCR&SNVS_LPCR_SRTC_ENV_MASK) != 0;

/* Stop SRTC time counter */
SNVS->LPCR &= ~SNVS_LPCR_SRTC_ENV_MASK;
while ((SNVS->LPCR & SNVS_LPCR_SRTC_ENV_MASK))
{
}
/* Disable SRTC alarm interrupt */
SNVS->LPCR &= ~SNVS_LPCR_LPTA_EN_MASK;
while ((SNVS->LPCR & SNVS_LPCR_LPTA_EN_MASK))
{
}

// Was SRTC active on entry?
if (lpsrtcEnabled)
{
    SNVS->LPCR |= SNVS_LPCR_SRTC_ENV_MASK;
    while ((0U == (SNVS->LPCR & SNVS_LPCR_SRTC_ENV_MASK)))
    {
    }
}

/* Synchronize RTC time and date with SRTC and start RTC */
SNVS_HP_RTC_TimeSynchronize(SNVS);
SNVS_HP_RTC_StartTimer(SNVS);

 

Best regards,

Jukka

0 Kudos
Reply
2 Replies

303 Views
Habib_MS
NXP Employee
NXP Employee

Hello @JLa63, sorry for the late reply.
Please make sure your oscillator meets the frequency specifications mentioned in Chapter 11, “External Input Clock Frequency,” of the datasheet.


Additionally, the “Clocks” chapter in the MIMXRT1050/MIMXRT1060 Hardware Design Guide provides recommendations to help avoid issues when using an external crystal.


On another note, the “HP Calibration Value” bits in the SNVS_HP Control Register (HPCR) can help you calibrate the RTC through software. You can find more details about this feature in section 20.3.3.1.1 “SNVS_HP Real Time Counter.”
Furthermore, you can measure the RTC frequency to determine the exact value your RTC is running at, and in based on this, see what the issue could be.
BR
Habib 

0 Kudos
Reply

175 Views
JLa63
Contributor III
Thank you for the response and sorry for my own late reply.
We are using crystal CM7V-T1A32.768KHZ7.0PF+/-20PPMTAQC, which is the same as in our other designs.
Our schematics has been approved by NXP team.

The error is about 0.15 per mil, setting the calibration value in HPCR and LPCR registers seems fix the problem.

I have the following additional questions:
- must the calibration value be set to both HPCR and LPCR registers?
- can the calibration value differ per device, i.e. is this something common thing for each MCU/crystal pair or should we calculate the unique calibration value for each device?
- is the temperature dependence only due to the crystal or is there some mcu related thing also messing things?
- main question of course is, why is there this kind of calibration needed if we have accurate crystal connected?

Rgrds, Jukka
0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2178695%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EMIMXRT1061C%20RTC%20accuracy%20with%20external%20chrystal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2178695%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EWe%20are%20using%20MIMXRT1061C%20MCU%20in%20our%20device%20with%20external%2032.768%20kHz%20crystal%20connected.%3C%2FP%3E%3CP%3EHowever%20it%20seems%20that%20RTC%20is%20ticking%20too%20fast%2C%20about%2010%20seconds%20in%2018%20hours%20at%20room%20temperature.%3C%2FP%3E%3CP%3ERelated%20registers%20should%20be%20correctly%20set%3A%3CBR%20%2F%3EXTALOSC24M_MISC0%200x24008080%3CBR%20%2F%3ECCM_ANALOG_MISC0%200x24008080%3C%2FP%3E%3CP%3EDo%20anybody%20have%20any%20idea%2C%20what%20could%20be%20wrong%3F%20Our%20other%20devices%20with%20same%20external%20crystal%20used%20have%20perfectly%20accurate%20RTC.%3C%2FP%3E%3CP%3ERTC%20initialization%20is%20done%20the%20following%20way%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Esnvs_lp_srtc_config_t%20snvsSrtcConfig%3D%20%7Bfalse%2C%200%7D%3B%0Asnvs_hp_rtc_config_t%20snvsRtcConfig%20%3D%20%7Bfalse%2C%200U%2C%200U%7D%3B%0A%0ASNVS_HP_RTC_Init(SNVS%2C%20%26amp%3BsnvsRtcConfig)%3B%0ASNVS_LP_SRTC_Init(SNVS%2C%20%26amp%3BsnvsSrtcConfig)%3B%0A%0ANVIC_ClearPendingIRQ(SNVS_HP_WRAPPER_IRQn)%3B%0ADisableIRQ(SNVS_HP_WRAPPER_IRQn)%3B%0AGPC_DisableIRQ(GPC%2C%20SNVS_HP_WRAPPER_IRQn)%3B%0A%0Abool%20lpsrtcEnabled%20%3D%20(SNVS-%26gt%3BLPCR%26amp%3BSNVS_LPCR_SRTC_ENV_MASK)%20!%3D%200%3B%0A%0A%2F*%20Stop%20SRTC%20time%20counter%20*%2F%0ASNVS-%26gt%3BLPCR%20%26amp%3B%3D%20~SNVS_LPCR_SRTC_ENV_MASK%3B%0Awhile%20((SNVS-%26gt%3BLPCR%20%26amp%3B%20SNVS_LPCR_SRTC_ENV_MASK))%0A%7B%0A%7D%0A%2F*%20Disable%20SRTC%20alarm%20interrupt%20*%2F%0ASNVS-%26gt%3BLPCR%20%26amp%3B%3D%20~SNVS_LPCR_LPTA_EN_MASK%3B%0Awhile%20((SNVS-%26gt%3BLPCR%20%26amp%3B%20SNVS_LPCR_LPTA_EN_MASK))%0A%7B%0A%7D%0A%0A%2F%2F%20Was%20SRTC%20active%20on%20entry%3F%0Aif%20(lpsrtcEnabled)%0A%7B%0A%20%20%20%20SNVS-%26gt%3BLPCR%20%7C%3D%20SNVS_LPCR_SRTC_ENV_MASK%3B%0A%20%20%20%20while%20((0U%20%3D%3D%20(SNVS-%26gt%3BLPCR%20%26amp%3B%20SNVS_LPCR_SRTC_ENV_MASK)))%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%7D%0A%0A%2F*%20Synchronize%20RTC%20time%20and%20date%20with%20SRTC%20and%20start%20RTC%20*%2F%0ASNVS_HP_RTC_TimeSynchronize(SNVS)%3B%0ASNVS_HP_RTC_StartTimer(SNVS)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CBR%20%2F%3E%3CP%3EBest%20regards%2C%3C%2FP%3E%3CP%3EJukka%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2206750%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MIMXRT1061C%20RTC%20accuracy%20with%20external%20chrystal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2206750%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EThank%20you%20for%20the%20response%20and%20sorry%20for%20my%20own%20late%20reply.%3CBR%20%2F%3EWe%20are%20using%20crystal%20CM7V-T1A32.768KHZ7.0PF%2B%2F-20PPMTAQC%2C%20which%20is%20the%20same%20as%20in%20our%20other%20designs.%3CBR%20%2F%3EOur%20schematics%20has%20been%20approved%20by%20NXP%20team.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20error%20is%20about%200.15%20per%20mil%2C%20setting%20the%20calibration%20value%20in%20HPCR%20and%20LPCR%20registers%20seems%20fix%20the%20problem.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20have%20the%20following%20additional%20questions%3A%3CBR%20%2F%3E-%20must%20the%20calibration%20value%20be%20set%20to%20both%20HPCR%20and%20LPCR%20registers%3F%3CBR%20%2F%3E-%20can%20the%20calibration%20value%20differ%20per%20device%2C%20i.e.%20is%20this%20something%20common%20thing%20for%20each%20MCU%2Fcrystal%20pair%20or%20should%20we%20calculate%20the%20unique%20calibration%20value%20for%20each%20device%3F%3CBR%20%2F%3E-%20is%20the%20temperature%20dependence%20only%20due%20to%20the%20crystal%20or%20is%20there%20some%20mcu%20related%20thing%20also%20messing%20things%3F%3CBR%20%2F%3E-%20main%20question%20of%20course%20is%2C%20why%20is%20there%20this%20kind%20of%20calibration%20needed%20if%20we%20have%20accurate%20crystal%20connected%3F%3CBR%20%2F%3E%3CBR%20%2F%3ERgrds%2C%20Jukka%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2182323%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20MIMXRT1061C%20RTC%20accuracy%20with%20external%20chrystal%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2182323%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F205508%22%20target%3D%22_blank%22%3E%40JLa63%3C%2FA%3E%2C%20sorry%20for%20the%20late%20reply.%3CBR%20%2F%3EPlease%20make%20sure%20your%20oscillator%20meets%20the%20frequency%20specifications%20mentioned%20in%20Chapter%2011%2C%20%E2%80%9CExternal%20Input%20Clock%20Frequency%2C%E2%80%9D%20of%20the%20%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fproducts%2Fi.MX-RT1060%23documentation%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Edatasheet%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EAdditionally%2C%20the%20%E2%80%9CClocks%E2%80%9D%20chapter%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.nxp.com%2Fbundle%2FMIMXRT105060HDUG%2Fpage%2Ftopics%2Fclocks.html%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EMIMXRT1050%2FMIMXRT1060%20Hardware%20Design%20Guide%3C%2FA%3E%20provides%20recommendations%20to%20help%20avoid%20issues%20when%20using%20an%20external%20crystal.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3EOn%20another%20note%2C%20the%20%E2%80%9CHP%20Calibration%20Value%E2%80%9D%20bits%20in%20the%20SNVS_HP%20Control%20Register%20(HPCR)%20can%20help%20you%20calibrate%20the%20RTC%20through%20software.%20You%20can%20find%20more%20details%20about%20this%20feature%20in%20section%2020.3.3.1.1%20%E2%80%9CSNVS_HP%20Real%20Time%20Counter.%E2%80%9D%3CBR%20%2F%3EFurthermore%2C%20you%20can%20measure%20the%20RTC%20frequency%20to%20determine%20the%20exact%20value%20your%20RTC%20is%20running%20at%2C%20and%20in%20based%20on%20this%2C%20see%20what%20the%20issue%20could%20be.%3CBR%20%2F%3EBR%3CBR%20%2F%3EHabib%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E