RTC Clock Trim

cgeber24

Active member
I have seen references in the forum to the ability to trim the RTC oscillator via SW registers, but can't find specifically how to do this - please help...

Thanks,
Chuck Geber
 
I have seen references in the forum to the ability to trim the RTC oscillator via SW registers, but can't find specifically how to do this - please help...

Thanks,
Chuck Geber
Not sure if this will work but this is what I can find.

Code:
void adjustRTCTrim(int8_t coarseTrim, int8_t fineTrim)
{
  // Disable the RTC before making adjustments
  RTC_CR &= ~RTC_CR_OSCE;  // Clear the RTC oscillator enable bit

  // Set the coarse and fine adjustments in the RTC_TCR register
  RTC_TCR = (coarseTrim << 8) | fineTrim;

  // Re-enable the RTC oscillator
  RTC_CR |= RTC_CR_OSCE;
}

void setup() {
  int8_t coarseTrim = 0;  // Coarse trim adjustment
  int8_t fineTrim = 0;    // Fine trim adjustment

  adjustRTCTrim(coarseTrim, fineTrim);
}
 
Which .h file contains the RTC register addresses and constants? I looked in imxrt.h but did not find them there....thanks!
 
Those constants may be T_3.x specific. Forum search using them found nothing except T_3.x refs :(

Not sure about similar mechanism for the 1062 MCU ...
 
For the 1062 there seems to be a SNVS_HPCR register with a bit called HPCALB_EN and a 5-bit signed field called HPCALB_VAL. You have to clear the HPCALB_EN bit, set HPCALB_VAL (which ranges from -16 to 15 ticks to add per 32768 ticks) and then set the HPCALB_EN bit again for the calibration to take effect.

There might be more info missing, particularly for the low-power RTC (the above is only for the high power RTC which runs when the system is fully powered) because large chunks of the basic reference manual seem to have been cut out and moved to the "Security Reference Manual" that is only available under NDA with NXP.
 
Back
Top