MSP430 DriverLib for MSP430FR5xx_6xx Devices  2.10.00.09
 All Data Structures Functions Variables Modules Pages
rtc_c

Functions

void RTC_C_startClock (uint16_t baseAddress)
 Starts the RTC. More...
 
void RTC_C_holdClock (uint16_t baseAddress)
 Holds the RTC. More...
 
void RTC_C_setCalibrationFrequency (uint16_t baseAddress, uint16_t frequencySelect)
 Allows and Sets the frequency output to RTCCLK pin for calibration measurement. More...
 
void RTC_C_setCalibrationData (uint16_t baseAddress, uint8_t offsetDirection, uint8_t offsetValue)
 Sets the specified calibration for the RTC. More...
 
void RTC_C_initCounter (uint16_t baseAddress, uint16_t clockSelect, uint16_t counterSizeSelect)
 Initializes the settings to operate the RTC in Counter mode. More...
 
bool RTC_C_setTemperatureCompensation (uint16_t baseAddress, uint16_t offsetDirection, uint8_t offsetValue)
 Sets the specified temperature compensation for the RTC. More...
 
void RTC_C_initCalendar (uint16_t baseAddress, Calendar *CalendarTime, uint16_t formatSelect)
 Initializes the settings to operate the RTC in calendar mode. More...
 
Calendar RTC_C_getCalendarTime (uint16_t baseAddress)
 Returns the Calendar Time stored in the Calendar registers of the RTC. More...
 
void RTC_C_configureCalendarAlarm (uint16_t baseAddress, RTC_C_configureCalendarAlarmParam *param)
 Sets and Enables the desired Calendar Alarm settings. More...
 
void RTC_C_setCalendarEvent (uint16_t baseAddress, uint16_t eventSelect)
 Sets a single specified Calendar interrupt condition. More...
 
uint32_t RTC_C_getCounterValue (uint16_t baseAddress)
 Returns the value of the Counter register. More...
 
void RTC_C_setCounterValue (uint16_t baseAddress, uint32_t counterValue)
 Sets the value of the Counter register. More...
 
void RTC_C_initCounterPrescale (uint16_t baseAddress, uint8_t prescaleSelect, uint16_t prescaleClockSelect, uint16_t prescaleDivider)
 Initializes the Prescaler for Counter mode. More...
 
void RTC_C_holdCounterPrescale (uint16_t baseAddress, uint8_t prescaleSelect)
 Holds the selected Prescaler. More...
 
void RTC_C_startCounterPrescale (uint16_t baseAddress, uint8_t prescaleSelect)
 Starts the selected Prescaler. More...
 
void RTC_C_definePrescaleEvent (uint16_t baseAddress, uint8_t prescaleSelect, uint8_t prescaleEventDivider)
 Sets up an interrupt condition for the selected Prescaler. More...
 
uint8_t RTC_C_getPrescaleValue (uint16_t baseAddress, uint8_t prescaleSelect)
 Returns the selected prescaler value. More...
 
void RTC_C_setPrescaleValue (uint16_t baseAddress, uint8_t prescaleSelect, uint8_t prescaleCounterValue)
 Sets the selected Prescaler value. More...
 
void RTC_C_enableInterrupt (uint16_t baseAddress, uint8_t interruptMask)
 Enables selected RTC interrupt sources. More...
 
void RTC_C_disableInterrupt (uint16_t baseAddress, uint8_t interruptMask)
 Disables selected RTC interrupt sources. More...
 
uint8_t RTC_C_getInterruptStatus (uint16_t baseAddress, uint8_t interruptFlagMask)
 Returns the status of the selected interrupts flags. More...
 
void RTC_C_clearInterrupt (uint16_t baseAddress, uint8_t interruptFlagMask)
 Clears selected RTC interrupt flags. More...
 
uint16_t RTC_C_convertBCDToBinary (uint16_t baseAddress, uint16_t valueToConvert)
 Convert the given BCD value to binary format. More...
 
uint16_t RTC_C_convertBinaryToBCD (uint16_t baseAddress, uint16_t valueToConvert)
 Convert the given binary value to BCD format. More...
 

Detailed Description

Function Documentation

void RTC_C_clearInterrupt ( uint16_t  baseAddress,
uint8_t  interruptFlagMask 
)

Clears selected RTC interrupt flags.

This function clears the RTC interrupt flag is cleared, so that it no longer asserts.

Parameters
baseAddressis the base address of the RTC_C module.
interruptFlagMaskis a bit mask of the interrupt flags to be cleared. Mask value is the logical OR of any of the following:
  • RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met.
  • RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in Calendar mode is met.
  • RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar registers are settled.
  • RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 event condition is met.
  • RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 event condition is met.
  • RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a problem with the 32kHz oscillator, while the RTC is running.
Returns
None
void RTC_C_configureCalendarAlarm ( uint16_t  baseAddress,
RTC_C_configureCalendarAlarmParam param 
)

Sets and Enables the desired Calendar Alarm settings.

This function sets a Calendar interrupt condition to assert the RTCAIFG interrupt flag. The condition is a logical and of all of the parameters. For example if the minutes and hours alarm is set, then the interrupt will only assert when the minutes AND the hours change to the specified setting. Use the RTC_C_ALARM_OFF for any alarm settings that should not be apart of the alarm condition.

Parameters
baseAddressis the base address of the RTC_C module.
paramis the pointer to struct for calendar alarm configuration.
Returns
None

References RTC_C_configureCalendarAlarmParam::dayOfMonthAlarm, RTC_C_configureCalendarAlarmParam::dayOfWeekAlarm, RTC_C_configureCalendarAlarmParam::hoursAlarm, and RTC_C_configureCalendarAlarmParam::minutesAlarm.

uint16_t RTC_C_convertBCDToBinary ( uint16_t  baseAddress,
uint16_t  valueToConvert 
)

Convert the given BCD value to binary format.

This function converts BCD values to binary format. This API uses the hardware registers to perform the conversion rather than a software method.

Parameters
baseAddressis the base address of the RTC_C module.
valueToConvertis the raw value in BCD format to convert to Binary.
Modified bits are BCD2BIN of BCD2BIN register.
Returns
The binary version of the input parameter
uint16_t RTC_C_convertBinaryToBCD ( uint16_t  baseAddress,
uint16_t  valueToConvert 
)

Convert the given binary value to BCD format.

This function converts binary values to BCD format. This API uses the hardware registers to perform the conversion rather than a software method.

Parameters
baseAddressis the base address of the RTC_C module.
valueToConvertis the raw value in Binary format to convert to BCD.
Modified bits are BIN2BCD of BIN2BCD register.
Returns
The BCD version of the valueToConvert parameter
void RTC_C_definePrescaleEvent ( uint16_t  baseAddress,
uint8_t  prescaleSelect,
uint8_t  prescaleEventDivider 
)

Sets up an interrupt condition for the selected Prescaler.

This function sets the condition for an interrupt to assert based on the individual prescalers.

Parameters
baseAddressis the base address of the RTC_C module.
prescaleSelectis the prescaler to define an interrupt for. Valid values are:
  • RTC_C_PRESCALE_0
  • RTC_C_PRESCALE_1
prescaleEventDivideris a divider to specify when an interrupt can occur based on the clock source of the selected prescaler. (Does not affect timer of the selected prescaler). Valid values are:
  • RTC_C_PSEVENTDIVIDER_2 [Default]
  • RTC_C_PSEVENTDIVIDER_4
  • RTC_C_PSEVENTDIVIDER_8
  • RTC_C_PSEVENTDIVIDER_16
  • RTC_C_PSEVENTDIVIDER_32
  • RTC_C_PSEVENTDIVIDER_64
  • RTC_C_PSEVENTDIVIDER_128
  • RTC_C_PSEVENTDIVIDER_256
    Modified bits are RTxIP of RTCPSxCTL register.
Returns
None
void RTC_C_disableInterrupt ( uint16_t  baseAddress,
uint8_t  interruptMask 
)

Disables selected RTC interrupt sources.

This function disables the selected RTC interrupt source. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

Parameters
baseAddressis the base address of the RTC_C module.
interruptMaskis a bit mask of the interrupts to disable. Mask value is the logical OR of any of the following:
  • RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met.
  • RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in Calendar mode is met.
  • RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar registers are settled.
  • RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 event condition is met.
  • RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 event condition is met.
  • RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a problem with the 32kHz oscillator, while the RTC is running.
Returns
None
void RTC_C_enableInterrupt ( uint16_t  baseAddress,
uint8_t  interruptMask 
)

Enables selected RTC interrupt sources.

This function enables the selected RTC interrupt source. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor. Does not clear interrupt flags.

Parameters
baseAddressis the base address of the RTC_C module.
interruptMaskis a bit mask of the interrupts to enable. Mask value is the logical OR of any of the following:
  • RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met.
  • RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in Calendar mode is met.
  • RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar registers are settled.
  • RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 event condition is met.
  • RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 event condition is met.
  • RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a problem with the 32kHz oscillator, while the RTC is running.
Returns
None
Calendar RTC_C_getCalendarTime ( uint16_t  baseAddress)

Returns the Calendar Time stored in the Calendar registers of the RTC.

This function returns the current Calendar time in the form of a Calendar structure. The RTCRDY polling is used in this function to prevent reading invalid time.

Parameters
baseAddressis the base address of the RTC_C module.
Returns
A Calendar structure containing the current time.

References Calendar::DayOfMonth, Calendar::DayOfWeek, Calendar::Hours, Calendar::Minutes, Calendar::Month, Calendar::Seconds, and Calendar::Year.

uint32_t RTC_C_getCounterValue ( uint16_t  baseAddress)

Returns the value of the Counter register.

This function returns the value of the counter register for the RTC_C module. It will return the 32-bit value no matter the size set during initialization. The RTC should be held before trying to use this function.

Parameters
baseAddressis the base address of the RTC_C module.
Returns
The raw value of the full 32-bit Counter Register.
uint8_t RTC_C_getInterruptStatus ( uint16_t  baseAddress,
uint8_t  interruptFlagMask 
)

Returns the status of the selected interrupts flags.

This function returns the status of the interrupt flag for the selected channel.

Parameters
baseAddressis the base address of the RTC_C module.
interruptFlagMaskis a bit mask of the interrupt flags to return the status of. Mask value is the logical OR of any of the following:
  • RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met.
  • RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in Calendar mode is met.
  • RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar registers are settled.
  • RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 event condition is met.
  • RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 event condition is met.
  • RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a problem with the 32kHz oscillator, while the RTC is running.
Returns
Logical OR of any of the following:
  • RTC_C_TIME_EVENT_INTERRUPT asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met.
  • RTC_C_CLOCK_ALARM_INTERRUPT asserts when alarm condition in Calendar mode is met.
  • RTC_C_CLOCK_READ_READY_INTERRUPT asserts when Calendar registers are settled.
  • RTC_C_PRESCALE_TIMER0_INTERRUPT asserts when Prescaler 0 event condition is met.
  • RTC_C_PRESCALE_TIMER1_INTERRUPT asserts when Prescaler 1 event condition is met.
  • RTC_C_OSCILLATOR_FAULT_INTERRUPT asserts if there is a problem with the 32kHz oscillator, while the RTC is running.
    indicating the status of the masked interrupts
uint8_t RTC_C_getPrescaleValue ( uint16_t  baseAddress,
uint8_t  prescaleSelect 
)

Returns the selected prescaler value.

This function returns the value of the selected prescale counter register. Note that the counter value should be held by calling RTC_C_holdClock() before calling this API.

Parameters
baseAddressis the base address of the RTC_C module.
prescaleSelectis the prescaler to obtain the value of. Valid values are:
  • RTC_C_PRESCALE_0
  • RTC_C_PRESCALE_1
Returns
The value of the specified prescaler count register
void RTC_C_holdClock ( uint16_t  baseAddress)

Holds the RTC.

This function sets the RTC main hold bit to disable RTC functionality.

Parameters
baseAddressis the base address of the RTC_C module.
Returns
None
void RTC_C_holdCounterPrescale ( uint16_t  baseAddress,
uint8_t  prescaleSelect 
)

Holds the selected Prescaler.

This function holds the prescale counter from continuing. This will only work in counter mode, in Calendar mode, the RTC_C_holdClock() must be used. In counter mode, if using both prescalers in conjunction with the main RTC counter, then stopping RT0PS will stop RT1PS, but stopping RT1PS will not stop RT0PS.

Parameters
baseAddressis the base address of the RTC_C module.
prescaleSelectis the prescaler to hold. Valid values are:
  • RTC_C_PRESCALE_0
  • RTC_C_PRESCALE_1
Returns
None
void RTC_C_initCalendar ( uint16_t  baseAddress,
Calendar CalendarTime,
uint16_t  formatSelect 
)

Initializes the settings to operate the RTC in calendar mode.

This function initializes the Calendar mode of the RTC module. To prevent potential erroneous alarm conditions from occurring, the alarm should be disabled by clearing the RTCAIE, RTCAIFG and AE bits with APIs: RTC_C_disableInterrupt(), RTC_C_clearInterrupt() and RTC_C_configureCalendarAlarm() before calendar initialization.

Parameters
baseAddressis the base address of the RTC_C module.
CalendarTimeis the pointer to the structure containing the values for the Calendar to be initialized to. Valid values should be of type pointer to Calendar and should contain the following members and corresponding values: Seconds between 0-59 Minutes between 0-59 Hours between 0-23 DayOfWeek between 0-6 DayOfMonth between 1-31 Year between 0-4095 NOTE: Values beyond the ones specified may result in erratic behavior.
formatSelectis the format for the Calendar registers to use. Valid values are:
  • RTC_C_FORMAT_BINARY [Default]
  • RTC_C_FORMAT_BCD
    Modified bits are RTCBCD of RTCCTL1 register.
Returns
None

References Calendar::DayOfMonth, Calendar::DayOfWeek, Calendar::Hours, Calendar::Minutes, Calendar::Month, Calendar::Seconds, and Calendar::Year.

void RTC_C_initCounter ( uint16_t  baseAddress,
uint16_t  clockSelect,
uint16_t  counterSizeSelect 
)

Initializes the settings to operate the RTC in Counter mode.

This function initializes the Counter mode of the RTC_C. Setting the clock source and counter size will allow an interrupt from the RTCTEVIFG once an overflow to the counter register occurs.

Parameters
baseAddressis the base address of the RTC_C module.
clockSelectis the selected clock for the counter mode to use. Valid values are:
  • RTC_C_CLOCKSELECT_32KHZ_OSC
  • RTC_C_CLOCKSELECT_RT1PS
    Modified bits are RTCSSEL of RTCCTL1 register.
counterSizeSelectis the size of the counter. Valid values are:
  • RTC_C_COUNTERSIZE_8BIT [Default]
  • RTC_C_COUNTERSIZE_16BIT
  • RTC_C_COUNTERSIZE_24BIT
  • RTC_C_COUNTERSIZE_32BIT
    Modified bits are RTCTEV of RTCCTL1 register.
Returns
None
void RTC_C_initCounterPrescale ( uint16_t  baseAddress,
uint8_t  prescaleSelect,
uint16_t  prescaleClockSelect,
uint16_t  prescaleDivider 
)

Initializes the Prescaler for Counter mode.

This function initializes the selected prescaler for the counter mode in the RTC_C module. If the RTC is initialized in Calendar mode, then these are automatically initialized. The Prescalers can be used to divide a clock source additionally before it gets to the main RTC clock.

Parameters
baseAddressis the base address of the RTC_C module.
prescaleSelectis the prescaler to initialize. Valid values are:
  • RTC_C_PRESCALE_0
  • RTC_C_PRESCALE_1
prescaleClockSelectis the clock to drive the selected prescaler. Valid values are:
  • RTC_C_PSCLOCKSELECT_ACLK
  • RTC_C_PSCLOCKSELECT_SMCLK
  • RTC_C_PSCLOCKSELECT_RT0PS - use Prescaler 0 as source to Prescaler 1 (May only be used if prescaleSelect is RTC_C_PRESCALE_1)
    Modified bits are RTxSSEL of RTCPSxCTL register.
prescaleDivideris the divider for the selected clock source. Valid values are:
  • RTC_C_PSDIVIDER_2 [Default]
  • RTC_C_PSDIVIDER_4
  • RTC_C_PSDIVIDER_8
  • RTC_C_PSDIVIDER_16
  • RTC_C_PSDIVIDER_32
  • RTC_C_PSDIVIDER_64
  • RTC_C_PSDIVIDER_128
  • RTC_C_PSDIVIDER_256
    Modified bits are RTxPSDIV of RTCPSxCTL register.
Returns
None
void RTC_C_setCalendarEvent ( uint16_t  baseAddress,
uint16_t  eventSelect 
)

Sets a single specified Calendar interrupt condition.

This function sets a specified event to assert the RTCTEVIFG interrupt. This interrupt is independent from the Calendar alarm interrupt.

Parameters
baseAddressis the base address of the RTC_C module.
eventSelectis the condition selected. Valid values are:
  • RTC_C_CALENDAREVENT_MINUTECHANGE - assert interrupt on every minute
  • RTC_C_CALENDAREVENT_HOURCHANGE - assert interrupt on every hour
  • RTC_C_CALENDAREVENT_NOON - assert interrupt when hour is 12
  • RTC_C_CALENDAREVENT_MIDNIGHT - assert interrupt when hour is 0
    Modified bits are RTCTEV of RTCCTL register.
Returns
None
void RTC_C_setCalibrationData ( uint16_t  baseAddress,
uint8_t  offsetDirection,
uint8_t  offsetValue 
)

Sets the specified calibration for the RTC.

This function sets the calibration offset to make the RTC as accurate as possible. The offsetDirection can be either +4-ppm or -2-ppm, and the offsetValue should be from 1-63 and is multiplied by the direction setting (i.e. +4-ppm * 8 (offsetValue) = +32-ppm).

Parameters
baseAddressis the base address of the RTC_C module.
offsetDirectionis the direction that the calibration offset will go. Valid values are:
  • RTC_C_CALIBRATION_DOWN1PPM - calibrate at steps of -1
  • RTC_C_CALIBRATION_UP1PPM - calibrate at steps of +1
    Modified bits are RTC0CALS of RTC0CAL register.
offsetValueis the value that the offset will be a factor of; a valid value is any integer from 1-240.
Modified bits are RTC0CALx of RTC0CAL register.
Returns
None
void RTC_C_setCalibrationFrequency ( uint16_t  baseAddress,
uint16_t  frequencySelect 
)

Allows and Sets the frequency output to RTCCLK pin for calibration measurement.

This function sets a frequency to measure at the RTCCLK output pin. After testing the set frequency, the calibration could be set accordingly.

Parameters
baseAddressis the base address of the RTC_C module.
frequencySelectis the frequency output to RTCCLK. Valid values are:
  • RTC_C_CALIBRATIONFREQ_OFF [Default] - turn off calibration output
  • RTC_C_CALIBRATIONFREQ_512HZ - output signal at 512Hz for calibration
  • RTC_C_CALIBRATIONFREQ_256HZ - output signal at 256Hz for calibration
  • RTC_C_CALIBRATIONFREQ_1HZ - output signal at 1Hz for calibration
    Modified bits are RTCCALF of RTCCTL3 register.
Returns
None
void RTC_C_setCounterValue ( uint16_t  baseAddress,
uint32_t  counterValue 
)

Sets the value of the Counter register.

This function sets the counter register of the RTC_C module.

Parameters
baseAddressis the base address of the RTC_C module.
counterValueis the value to set the Counter register to; a valid value may be any 32-bit integer.
Returns
None
void RTC_C_setPrescaleValue ( uint16_t  baseAddress,
uint8_t  prescaleSelect,
uint8_t  prescaleCounterValue 
)

Sets the selected Prescaler value.

This function sets the prescale counter value. Before setting the prescale counter, it should be held by calling RTC_C_holdClock().

Parameters
baseAddressis the base address of the RTC_C module.
prescaleSelectis the prescaler to set the value for. Valid values are:
  • RTC_C_PRESCALE_0
  • RTC_C_PRESCALE_1
prescaleCounterValueis the specified value to set the prescaler to. Valid values are any integer between 0-255
Modified bits are RTxPS of RTxPS register.
Returns
None
bool RTC_C_setTemperatureCompensation ( uint16_t  baseAddress,
uint16_t  offsetDirection,
uint8_t  offsetValue 
)

Sets the specified temperature compensation for the RTC.

This function sets the calibration offset to make the RTC as accurate as possible. The offsetDirection can be either +1-ppm or -1-ppm, and the offsetValue should be from 1-240 and is multiplied by the direction setting (i.e. +1-ppm * 8 (offsetValue) = +8-ppm).

Parameters
baseAddressis the base address of the RTC_C module.
offsetDirectionis the direction that the calibration offset wil go Valid values are:
  • RTC_C_COMPENSATION_DOWN1PPM
  • RTC_C_COMPENSATION_UP1PPM
    Modified bits are RTCTCMPS of RTCTCMP register.
offsetValueis the value that the offset will be a factor of; a valid value is any integer from 1-240.
Modified bits are RTCTCMPx of RTCTCMP register.
Returns
STATUS_SUCCESS or STATUS_FAILURE of setting the temperature compensation
void RTC_C_startClock ( uint16_t  baseAddress)

Starts the RTC.

This function clears the RTC main hold bit to allow the RTC to function.

Parameters
baseAddressis the base address of the RTC_C module.
Returns
None
void RTC_C_startCounterPrescale ( uint16_t  baseAddress,
uint8_t  prescaleSelect 
)

Starts the selected Prescaler.

This function starts the selected prescale counter. This function will only work if the RTC is in counter mode.

Parameters
baseAddressis the base address of the RTC_C module.
prescaleSelectis the prescaler to start. Valid values are:
  • RTC_C_PRESCALE_0
  • RTC_C_PRESCALE_1
Returns
None

Copyright 2015, Texas Instruments Incorporated