RTC
 
Component RTC
Real Time Clock
Component Level: High
Methods:
(Methods are user-callable functions/subroutines intended for the component functions control. Please see the Embedded Components page for more information.)
  • Enable - Enable the component - it starts the signal generation. Events can be disabled/enabled by "DisableEvent"/"EnableEvent".

      ANSIC prototype: byte Enable(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK
      ERR_PROTECT - Registers are protected (MC68HC908LK24/MC68HC908LJ24 derivatives only)

  • Disable - Disable the component - it stops signal generation and events calling.

      ANSIC prototype: byte Disable(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK
      ERR_PROTECT - Registers are protected (MC68HC908LK24/MC68HC908LJ24 derivatives only)

  • EnableEvent - This method enables the events. This method is available only if any event is selected in the component.

      ANSIC prototype: byte EnableEvent(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • DisableEvent - This method disables the events. This method is available only if any event is selected in the component.

      ANSIC prototype: byte DisableEvent(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • EnableAlarm - Enable alarm of the RTC (method is available only when the event OnAlarm is generated - "generate code").

      ANSIC prototype: byte EnableAlarm(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • DisableAlarm - Disable alarm of the RTC. (method is available only when the event OnAlarm is generated - "generate code" )

      ANSIC prototype: byte DisableAlarm(void)
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • Methods for HC08 derivatives.
    • EnableChronograph - Enable chronograph counter. Note: The chronograph is enabled if the whole RTC device is enabled (see Enabled/Disable methods).

        ANSIC prototype: byte EnableChronograph(void)
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK

    • DisableChronograph - Disable chronograph counter.

        ANSIC prototype: byte DisableChronograph(void)
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK

    • ClearChronograph - Clear chronograph counter register.

        ANSIC prototype: byte ClearChronograph(void)
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK

    • GetChronograph - Get the value of chronograph counter register.

        ANSIC prototype: byte GetChronograph(void)
      • Return value:byte - Value of the chronograph counter.

  • Methods for non-MCF and non-ColdFireV1 derivatives.
    • SetAlarm - Set alarm time (hour and minute). (method is available only when the event OnAlarm is generated - "generate code")

        ANSIC prototype: byte SetAlarm(byte Hour, byte Min)
      • Hour:byte - Hours (0 - 23)
      • Min:byte - Minute (0 - 59)
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_RANGE - Parameter out of range

  • Methods for MCF and ColdFireV1 derivatives.
    • SetAlarm - Set alarm time (hour, minute and second). (method is available only when the event OnAlarm is generated - "generate code")

        ANSIC prototype: byte SetAlarm(byte Hour, byte Min, byte Sec)
      • Hour:byte - Hours (0 - 23)
      • Min:byte - Minute (0 - 59)
      • Sec:byte - Seconds (0 - 59)
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_RANGE - Parameter out of range

  • GetAlarm - Get alarm time (hour and minute) in ALARMREC structure. (method is available only when the event OnAlarm is generated - "generate code")

      ANSIC prototype: byte GetAlarm(ALARMREC *Time)
    • Time: Pointer to ALARMREC - Pointer to the ALARMREC structure. It contains hour and minute.
    • Return value:byte - Error code, possible codes:
      ERR_OK - OK

  • Methods only if RTC supports alarm with days, months, and years
    • SetAlarmDate - Set alarm date (year, month and day). (method is available only when the event OnAlarm is generated - "generate code")
      For ColdFireV1 derivatives the method is available only when the property Component Mode is set to - "Full".

        ANSIC prototype: byte SetAlarmDate(word Year, byte Month, byte Day)
      • Year:word - Year (1984 - 2239)
      • Month:byte - Month (1 - 12)
      • Day:byte - Day (1 - 28/29/30/31)
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_RANGE - Parameter out of range

    • GetAlarmDate - Get alarm date (year, month and day) in DATEREC structure. (method is available only when the event OnAlarm is generated - "generate code")
      For ColdFireV1 derivatives the method is available only when the property Component Mode is set to - "Full".

        ANSIC prototype: byte GetAlarmDate(DATEREC *Date)
      • Date: Pointer to DATEREC - Pointer to the DATAREC structure. It contains year, month and day.
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK

  • Methods for HC08 derivatives.
    • GetStatus - Get and clear status register (interrupt flags).

        ANSIC prototype: byte GetStatus(byte *Flags)
      • Flags: Pointer to byte - Pointer to returned flags
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK

  • Methods only if RTC alarm supports definition of matched values
    • SetAlarmCond - Set alarm condition (method is available only when the event OnAlarm is generated - "generate code" and property Component Mode is set to - "Full")

        ANSIC prototype: byte SetAlarmCond(byte Required)
      • Required:byte - Alarm requirement bit mask. Alarm requires match of
        0 - seconds, minutes and hours.
        1 - seconds, minutes, hours and days.
        2 - seconds, minutes, hours, days and months.
        3 - seconds, minutes, hours, days, months nad year.
      • Return value:byte - Error code

  • SetTime - Set a new actual time (hour, minute and second).

      ANSIC prototype: byte SetTime(byte Hour, byte Min, byte Sec)
    • Hour:byte - Hours (0 - 23)
    • Min:byte - Minutes (0 - 59)
    • Sec:byte - Seconds (0 - 59)
    • Return value:byte - Error code, possible codes:
      • ERR_OK - OK
      • ERR_RANGE - Parameter out of range
      • ERR_BUSY - Device is busy for ColdFireV1 derivatives
      • ERR_PROTECT - Registers are protected (MC68HC908LK24/MC68HC908LJ24 derivatives only)
      • ERR_ENABLED - Device is enabled. Write to registers is not possible (56800 family only)

  • GetTime - Get current time (hour, minute and second).

      ANSIC prototype: byte GetTime(TIMEREC *Time)
    • Time: Pointer to TIMEREC - Pointer to the structure TIMEREC. It contains actual number of hours, minutes and seconds.
    • Return value:byte - Error code, possible codes:
      • ERR_OK - OK
      • ERR_BUSY - Device is busy for ColdFireV1 derivatives

  • Methods for HC08, ColdFireV1 and MCF5441x derivatives.
    • SetDate - Set a new actual date (year, month and day).
      For ColdFireV1 derivatives the method is available only when the property Component Mode is set to - "Full".

        ANSIC prototype: byte SetDate(word Year, byte Month, byte Day)
      • Year:word -
        Year (1901 - 2099) for HC08 derivatives
        Year (1984 - 2239) for ColdFireV1 derivatives
      • Month:byte - Month (1 - 12)
      • Day:byte - Day (1 - 28/29/30/31)
      • Return value:byte - Error code, possible codes:
        • ERR_OK - OK
        • ERR_RANGE - Parameter out of range
        • ERR_BUSY - Device is busy for ColdFireV1 derivatives
        • ERR_PROTECT - Registers are protected (MC68HC908LK24/MC68HC908LJ24 derivatives only)

    • GetDate - Get current date (year, month and day).
      For ColdFireV1 derivatives the method is available only when the property Component Mode is set to - "Full".

        ANSIC prototype: byte GetDate(DATEREC *Date)
      • Date: Pointer to DATEREC - Pointer to the DATAREC structure. It contains year, month and day.
      • Return value:byte - Error code, possible codes:
        • ERR_OK - OK
        • ERR_BUSY - Device is busy for ColdFireV1 derivatives

    • SetDayOfWeek - Set new day of week.
      For ColdFireV1 derivatives the method is available only when the property Component Mode is set to - "Full".

        ANSIC prototype: byte SetDayOfWeek(DAYOFWEEK Day)
      • Day:DAYOFWEEK - Day of week (Monday - Sunday)
      • Return value:byte - Error code, possible codes:
        • ERR_OK - OK
        • ERR_RANGE - Parameter out of range
        • ERR_BUSY - Device is busy for ColdFireV1 derivatives
        • ERR_PROTECT - Registers are protected (MC68HC908LK24/MC68HC908LJ24 derivatives only)

    • GetDayOfWeek - Get day of week.
      For ColdFireV1 derivatives the method is available only when the property Component Mode is set to - "Full".

        ANSIC prototype: byte GetDayOfWeek(DAYOFWEEK *Day)
      • Day: Pointer to DAYOFWEEK - Pointer to day of week variable
      • Return value:byte - Error code, possible codes:
        • ERR_OK - OK
        • ERR_BUSY - Device is busy for ColdFireV1 derivatives

  • Methods for MC68HC908LK24/MC68HC908LJ24 derivatives.
    • StartCalibration - This method starts the automatic/manual calibration process. The automatic calibration requires to connect high accurate 1Hz square wave pulse train into CALIN pin. During the calibration the RTC device compares difference between the two clock source for 15 second.

        ANSIC prototype: byte StartCalibration(bool Automatic, byte calValue)
      • Automatic:bool - Whether the calibration will be automatic or not (true - automatic calibration, false - manual calibration).
      • calValue:byte - The calibration value for manual calibration of the RTC module.
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_PROTECT - Registers are protected (MC68HC908LK24/MC68HC908LJ24 derivatives only)

    • StopCalibration - This method stops the calibration process.

        ANSIC prototype: byte StopCalibration(void)
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_PROTECT - Registers are protected (MC68HC908LK24/MC68HC908LJ24 derivatives only)

    • GetCalibrationData - This method returns the value of the calibration data register.

        ANSIC prototype: byte GetCalibrationData(byte *Data)
      • Data: Pointer to byte - Pointer to a variable. The return value will contain the content of the Calibration data register. The value is 6 bit length in 2's complement format.
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_OVERFLOW - The calibration data register overflow

    • ProtectRegisters - This method protects the real time clock and important operating parameters in order to prevent accidental overwriting. The protected registers (bits) are Calibration Register (CAL, AUTOCAL, OUTF), Control Register (COMEN, RTCE), Second Register, Minutes Register, Hours Register, Days Register, Months Register, Years Register and Day of Week Register. The Enable, Disable, SetTime, SetDate, SetDayOfWeek methods StartAutomaticCalibration methods are blocked.

        ANSIC prototype: void ProtectRegisters(void)

    • UnprotectRegisters - This method unprotects the real time clock and important operating parameters. The unprotected registers (bits) are Calibration Register (CAL, AUTOCAL, OUTF), Control Register (COMEN, RTCE), Second Register, Minutes Register, Hours Register, Days Register, Months Register, Years Register and Day of Week Register. The Enable, Disable, SetTime, SetDate, SetDayOfWeek methods StartAutomaticCalibration methods are not blocked.

        ANSIC prototype: void UnprotectRegisters(void)

    • SetCalibrationOutputMode - This method sets the calibration mode of the calibration output pin.

        ANSIC prototype: byte SetCalibrationOutputMode(CLOCKOUTPUTMODE Mode)
      • Mode:CLOCKOUTPUTMODE - Mode of the calibration output pin. The pin can be disconnected or it can outputs compensated 1Hz signal or crystal oscillator frequency.
      • Return value:byte - Error code, possible codes:
        ERR_OK - OK
        ERR_RANGE - The mode parameter has illegal value.

    • SetCompensation - This method enable/disable automatic compensation of the RTC.

        ANSIC prototype: void SetCompensation(bool Compensation)
      • Compensation:bool - Enabled/disable compensation mechanism of the RTC.

  • Methods only if RTC supports crystal compensation
    • SetCompensation - This method sets compensation of crystal speed. Compensation is based on adding or removing crystal pulses during defined interval. Interval = 0 disables compensation.
      For ColdFireV1 derivatives the method is available only when the property Component Mode is set to - "Full".

        ANSIC prototype: void SetCompensation(signed char Pulse, byte Interval)
      • Pulse:signed char - This parameter defines number of crystal pulses added (+) or removed (-) during time defined by next parameter.
      • Interval:byte - This parameter defines numbers of seconds when is previous parameter applied.
        Zero disables compensation.

    • CompensationDone - This method informs whether compensation interval already passes.
      Value is checked since last question. The method is used to fit compensation interval to other appropriate signal.
      For ColdFireV1 derivatives the method is available only when the property Component Mode is set to - "Full".

        ANSIC prototype: bool CompensationDone(void)
      • Return value:bool - Is compensation done.
        True if yes, else False.

  • Methods for HC08, ColdFireV1 and MCF5441x derivatives.
    • Init - Initializes the associated peripheral(s) and the component internal variables. The method is called automatically as a part of the application initialization code.
      Version specific information for MCF5441x and ColdFireV1 derivatives
      Method can be called from user code (see property "InitAfterReset")

        ANSIC prototype: void Init(void)


Note: Some methods can be implemented as macros.