Functions
rtc.c File Reference
#include "driverlib/5xx_6xx/rtc.h"
#include "inc/hw_types.h"
#include "deprecated/CCS/msp430xgeneric.h"
#include "driverlib/5xx_6xx/debug.h"

Functions

void RTC_startClock (unsigned int baseAddress)
void RTC_holdClock (unsigned int baseAddress)
void RTC_setCalibrationFrequency (unsigned int baseAddress, unsigned int frequencySelect)
void RTC_setCalibrationData (unsigned int baseAddress, unsigned char offsetDirection, unsigned char offsetValue)
void RTC_counterInit (unsigned int baseAddress, unsigned int clockSelect, unsigned int counterSizeSelect)
void RTC_calendarInit (unsigned int baseAddress, Calendar CalendarTime, unsigned int formatSelect)
Calendar RTC_getCalendarTime (unsigned int baseAddress)
void RTC_setCalendarAlarm (unsigned int baseAddress, unsigned char minutesAlarm, unsigned char hoursAlarm, unsigned char dayOfWeekAlarm, unsigned char dayOfMonthAlarm)
void RTC_setCalendarEvent (unsigned int baseAddress, unsigned int eventSelect)
unsigned long RTC_getCounterValue (unsigned int baseAddress)
void RTC_setCounterValue (unsigned int baseAddress, unsigned long counterValue)
void RTC_counterPrescaleInit (unsigned int baseAddress, unsigned char prescaleSelect, unsigned int prescaleClockSelect, unsigned int prescaleDivider)
void RTC_counterPrescaleHold (unsigned int baseAddress, unsigned char prescaleSelect)
void RTC_counterPrescaleStart (unsigned int baseAddress, unsigned char prescaleSelect)
void RTC_definePrescaleEvent (unsigned int baseAddress, unsigned char prescaleSelect, unsigned char prescaleEventDivider)
unsigned char RTC_getPrescaleValue (unsigned int baseAddress, unsigned char prescaleSelect)
void RTC_setPrescaleCounterValue (unsigned int baseAddress, unsigned char prescaleSelect, unsigned char prescaleCounterValue)
void RTC_enableInterrupt (unsigned int baseAddress, unsigned char interruptMask)
void RTC_disableInterrupt (unsigned int baseAddress, unsigned char interruptMask)
unsigned char RTC_getInterruptStatus (unsigned int baseAddress, unsigned char interruptFlagMask)
void RTC_clearInterrupt (unsigned int baseAddress, unsigned char interruptFlagMask)
unsigned int RTC_convertBCDToBinary (unsigned int baseAddress, unsigned int valueToConvert)
unsigned int RTC_convertBinaryToBCD (unsigned int baseAddress, unsigned int valueToConvert)

Function Documentation

void RTC_startClock ( unsigned int  baseAddress)

Starts the RTC.

Parameters:
baseAddressis the base address of the RTC module.

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

Returns:
None

References HWREGB.

void RTC_holdClock ( unsigned int  baseAddress)

Holds the RTC.

Parameters:
baseAddressis the base address of the RTC module.

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

Returns:
None

References HWREGB.

void RTC_setCalibrationFrequency ( unsigned int  baseAddress,
unsigned int  frequencySelect 
)

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

Parameters:
baseAddressis the base address of the RTC module.
frequencySelectis the frequency output to RTCCLK. Valid values are RTC_CALIBRATIONFREQ_OFF - turn off calibration output [Default] RTC_CALIBRATIONFREQ_512HZ - output signal at 512Hz for calibration RTC_CALIBRATIONFREQ_256HZ - output signal at 256Hz for calibration RTC_CALIBRATIONFREQ_1HZ - output signal at 1Hz for calibration Modified bits are RTCCALF of RTCCTL3 register.

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

Returns:
None

References HWREGB.

void RTC_setCalibrationData ( unsigned int  baseAddress,
unsigned char  offsetDirection,
unsigned char  offsetValue 
)

Sets the specified calibration for the RTC.

Parameters:
baseAddressis the base address of the RTC module.
offsetDirectionis the direction that the calibration offset will go. Valid values are RTC_CALIBRATION_DOWN2PPM - calibrate at steps of -2 RTC_CALIBRATION_UP4PPM - calibrat at steps of +4 Modified bits are RTCCALS of RTCCTL2 register.
offsetValueis the value that the offset will be a factor of; a valid value is any integer from 1-63. Modified bits are RTCCAL of RTCCTL2 register.

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). Please note, when measuring the frequency after setting the calibration, you will only see a change on the 1Hz frequency.

Returns:
None

References HWREGB.

void RTC_counterInit ( unsigned int  baseAddress,
unsigned int  clockSelect,
unsigned int  counterSizeSelect 
)

Initializes the settings to operate the RTC in Counter mode (RTC_A ONLY).

Parameters:
baseAddressis the base address of the RTC module.
clockSelectis the selected clock for the counter mode to use. Valid values are RTC_CLOCKSELECT_ACLK [Default] RTC_CLOCKsELECT_SMCLK RTC_CLOCKSELECT_RT1PS - use Prescaler 1 as source to RTC Modified bits are RTCSSEL of RTCCTL1 register.
counterSizeSelectis the size of the counter. Valid values are RTC_COUNTERSIZE_8BIT [Default] RTC_COUNTERSIZE_16BIT RTC_COUNTERSIZE_24BIT RTC_COUNTERSIZE_32BIT Modified bits are RTCTEV of RTCCTL1 register.

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

Returns:
None

References HWREG, and HWREGB.

void RTC_calendarInit ( unsigned int  baseAddress,
Calendar  CalendarTime,
unsigned int  formatSelect 
)

Initializes the settings to operate the RTC in Calendar mode.

Parameters:
baseAddressis the base address of the RTC module.
CalendarTimeis the structure containing the values for the Calendar to be intiialized to. Valid values should be of type Calendar and should contain the following members and corresponding values: Seconds between 0-59 Minutes between 0-59 Hours between 0-24 DayOfWeek between 0-6 DayOfMonth between 0-31 Year between 0-4095 NOTE: Values beyond the ones specified may result in eradic behavior.
formatSelectis the format for the Calendar registers to use. Valid values are RTC_FORMAT_BINARY [Default] RTC_FORMAT_BCD Modified bits are RTCBCD of RTCCTL1 register.

This function initializes the Calendar mode of the RTC module. In an RTC_A module this mode automatically sets the clock source to ACLK and initializes the prescaler sources and dividers.

Returns:
None

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

Calendar RTC_getCalendarTime ( unsigned int  baseAddress)

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

Parameters:
baseAddressis the base address of the RTC module.

This function returns the current Calendar time in the form of a Calendar structure.

Returns:
A Calendar structure containing the current time.

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

void RTC_setCalendarAlarm ( unsigned int  baseAddress,
unsigned char  minutesAlarm,
unsigned char  hoursAlarm,
unsigned char  dayOfWeekAlarm,
unsigned char  dayOfMonthAlarm 
)

Sets and Enables the desired Calendar Alarm settings.

Parameters:
baseAddressis the base address of the RTC module.
minutesAlarmis the alarm condition for the minutes. Valid values are An integer between 0-59, OR RTC_ALARMCONDITION_OFF [Default]
hoursAlarmis the alarm condition for the hours. Valid values are An integer between 0-24, OR RTC_ALARMCONDITION_OFF [Default]
dayOfWeekAlarmis the alarm condition for the day of week. Valid values are An integer between 0-6, OR RTC_ALARMCONDITION_OFF [Default]
dayOfMonthAlarmis the alarm condition for the day of the month. Valid values are An integer between 0-31, OR RTC_ALARMCONDITION_OFF [Default]

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_ALARM_OFF for any alarm settings that should not be apart of the alarm condition.

Returns:
None

References HWREGB.

void RTC_setCalendarEvent ( unsigned int  baseAddress,
unsigned int  eventSelect 
)

Sets a single specified Calendar interrupt condition.

Parameters:
baseAddressis the base address of the RTC module.
eventSelectis the condition selected. Valid values are RTC_CALENDAREVENT_MINUTECHANGE - assert interrupt on every minute RTC_CALENDAREVENT_HOURCHANGE - assert interrupt on every hour RTC_CALENDAREVENT_NOON - assert interrupt when hour is 12 RTC_CALENDAREVENT_MIDNIGHT - assert interrupt when hour is 0 Modified bits are RTCTEV of RTCCTL register.

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

Returns:
None

References HWREG.

unsigned long RTC_getCounterValue ( unsigned int  baseAddress)

Returns the value of the Counter register (RTC_A ONLY).

Parameters:
baseAddressis the base address of the RTC module.

This function returns the value of the counter register for the RTC_A 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.

Returns:
The raw value of the full 32-bit Counter Register.

References HWREG, and HWREGB.

void RTC_setCounterValue ( unsigned int  baseAddress,
unsigned long  counterValue 
)

Sets the value of the Counter register (RTC_A ONLY).

Parameters:
baseAddressis the base address of the RTC module.
counterValueis the value to set the Counter register to; a valid value may be any 32-bit integer.

This function sets the counter register of the RTC_A module.

Returns:
None

References HWREG.

void RTC_counterPrescaleInit ( unsigned int  baseAddress,
unsigned char  prescaleSelect,
unsigned int  prescaleClockSelect,
unsigned int  prescaleDivider 
)

Initializes the Prescaler for Counter mode (RTC_A ONLY).

Parameters:
baseAddressis the base address of the RTC module.
prescaleSelectis the prescaler to initialize. Valid values are RTC_PRESCALE_0 RTC_PRESCALE_1
prescaleClockSelectis the clock to drive the selected prescaler. Valid values are RTC_CLOCKSELECT_ACLK [Default] RTC_CLOCKSELECT_SMCLK RTC_CLOCKSELECT_RT0PS - use Prescaler 0 as source to Prescaler 1 (May only be used if prescaleSelect is RTC_PRESCALE_1) Modified bits are RTxSSEL of RTCPSxCTL register.
prescaleDivideris the divider for the selected clock source. Valid values are RTC_PSDIVIDER_2 [Default] RTC_PSDIVIDER_4 RTC_PSDIVIDER_8 RTC_PSDIVIDER_16 RTC_PSDIVIDER_32 RTC_PSDIVIDER_64 RTC_PSDIVIDER_128 RTC_PSDIVIDER_256 Modified bits are RTxPSDIV of RTCPSxCTL register.

This function initializes the selected prescaler for the counter mode in the RTC_A 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.

Returns:
None

References HWREG.

void RTC_counterPrescaleHold ( unsigned int  baseAddress,
unsigned char  prescaleSelect 
)

Holds the selected Prescaler (RTC_A ONLY).

Parameters:
baseAddressis the base address of the RTC module.
prescaleSelectis the prescaler to hold. Valid values are RTC_PRESCALE_0 RTC_PRESCALE_1

This function holds the prescale counter from continuing. This will only work in counter mode, in Calendar mode, the RTC_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.

Returns:
None

References HWREGB.

void RTC_counterPrescaleStart ( unsigned int  baseAddress,
unsigned char  prescaleSelect 
)

Starts the selected Prescaler (RTC_A ONLY).

Parameters:
baseAddressis the base address of the RTC module.
prescaleSelectis the prescaler to start. Valid values are RTC_PRESCALE_0 RTC_PRESCALE_1

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

Returns:
None

References HWREGB.

void RTC_definePrescaleEvent ( unsigned int  baseAddress,
unsigned char  prescaleSelect,
unsigned char  prescaleEventDivider 
)

Sets up an interrupt condition for the selected Prescaler.

Parameters:
baseAddressis the base address of the RTC module.
prescaleSelectis the prescaler to define an interrupt for. Valid values are RTC_PRESCALE_0 RTC_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_PSEVENTDIVIDER_2 [Default] RTC_PSEVENTDIVIDER_4 RTC_PSEVENTDIVIDER_8 RTC_PSEVENTDIVIDER_16 RTC_PSEVENTDIVIDER_32 RTC_PSEVENTDIVIDER_64 RTC_PSEVENTDIVIDER_128 RTC_PSEVENTDIVIDER_256 Modified bits are RTxIP of RTCPSxCTL register.

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

Returns:
None

References HWREGB.

unsigned char RTC_getPrescaleValue ( unsigned int  baseAddress,
unsigned char  prescaleSelect 
)

Returns the selected Prescaler value.

Parameters:
baseAddressis the base address of the RTC module.
prescaleSelectis the prescaler to obtain the value of. Valid values are RTC_PRESCALE_0 RTC_PRESCALE_1

This function returns the value of the selected prescale counter register. The counter should be held before reading. If in counter mode, the individual prescaler can be held, while in Calendar mode the whole RTC must be held.

Returns:
The value of the specified Prescaler count register

References HWREGB, RTC_PRESCALE_0, and RTC_PRESCALE_1.

void RTC_setPrescaleCounterValue ( unsigned int  baseAddress,
unsigned char  prescaleSelect,
unsigned char  prescaleCounterValue 
)

Sets the selected Prescaler value.

Parameters:
baseAddressis the base address of the RTC module.
prescaleSelectis the prescaler to set the value for. Valid values are RTC_PRESCALE_0 RTC_PRESCALE_1
prescaleCounterValueis the specified value to set the prescaler to; a valid value is any integer from 0-255. Modified bits are RTxPS of RTxPS register.

This function sets the prescale counter value. Before setting the prescale counter, it should be held.

Returns:
None

References HWREGB, RTC_PRESCALE_0, and RTC_PRESCALE_1.

void RTC_enableInterrupt ( unsigned int  baseAddress,
unsigned char  interruptMask 
)

Enables selected RTC interrupt sources.

Parameters:
baseAddressis the base address of the RTC module.
interruptMaskis a bit mask of the interrupts to enable. Mask Value is the logical OR of any of the following RTC_TIME_EVENT_INTERRUPT - asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met. RTC_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in Calendar mode is met. RTC_CLOCK_READ_READY_INTERRUPT - asserts when Calendar registers are settled. RTC_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 event condition is met. RTC_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 event condition is met. RTC_OSCILLATOR_FAULT_INTERRUPT (RTC_B ONLY) - asserts if there is a problem with the 32kHz oscillator, while the RTC is running.

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.

Returns:
None

References HWREGB, RTC_PRESCALE_TIMER0_INTERRUPT, and RTC_PRESCALE_TIMER1_INTERRUPT.

void RTC_disableInterrupt ( unsigned int  baseAddress,
unsigned char  interruptMask 
)

Disables selected RTC interrupt sources.

Parameters:
baseAddressis the base address of the RTC module.
interruptMaskis a bit mask of the interrupts to disable. Mask Value is the logical OR of any of the following RTC_TIME_EVENT_INTERRUPT - asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met. RTC_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in Calendar mode is met. RTC_CLOCK_READ_READY_INTERRUPT - asserts when Calendar registers are settled. RTC_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 event condition is met. RTC_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 event condition is met. RTC_OSCILLATOR_FAULT_INTERRUPT (RTC_B ONLY) - asserts if there is a problem with the 32kHz oscillator, while the RTC is running.

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.

Returns:
None

References HWREGB, RTC_PRESCALE_TIMER0_INTERRUPT, and RTC_PRESCALE_TIMER1_INTERRUPT.

unsigned char RTC_getInterruptStatus ( unsigned int  baseAddress,
unsigned char  interruptFlagMask 
)

Returns the status of the selected interrupts flags.

Parameters:
baseAddressis the base address of the RTC 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_TIME_EVENT_INTERRUPT - asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met. RTC_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in Calendar mode is met. RTC_CLOCK_READ_READY_INTERRUPT - asserts when Calendar registers are settled. RTC_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 event condition is met. RTC_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 event condition is met. RTC_OSCILLATOR_FAULT_INTERRUPT (RTC_B ONLY) - asserts if there is a problem with the 32kHz oscillator, while the RTC is running.

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

Returns:
A bit mask of the selected interrupt flag's status.

References HWREGB, RTC_PRESCALE_TIMER0_INTERRUPT, and RTC_PRESCALE_TIMER1_INTERRUPT.

void RTC_clearInterrupt ( unsigned int  baseAddress,
unsigned char  interruptFlagMask 
)

Clears selected RTC interrupt flags.

Parameters:
baseAddressis the base address of the RTC module.
interruptFlagMaskis a bit mask of the interrupt flags to be cleared. Mask Value is the logical OR of any of the following RTC_TIME_EVENT_INTERRUPT - asserts when counter overflows in counter mode or when Calendar event condition defined by defineCalendarEvent() is met. RTC_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in Calendar mode is met. RTC_CLOCK_READ_READY_INTERRUPT - asserts when Calendar registers are settled. RTC_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 event condition is met. RTC_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 event condition is met. RTC_OSCILLATOR_FAULT_INTERRUPT (RTC_B ONLY) - asserts if there is a problem with the 32kHz oscillator, while the RTC is running.

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

Returns:
None

References HWREGB, RTC_CLOCK_ALARM_INTERRUPT, RTC_CLOCK_READ_READY_INTERRUPT, RTC_OSCILLATOR_FAULT_INTERRUPT, RTC_PRESCALE_TIMER0_INTERRUPT, RTC_PRESCALE_TIMER1_INTERRUPT, and RTC_TIME_EVENT_INTERRUPT.

unsigned int RTC_convertBCDToBinary ( unsigned int  baseAddress,
unsigned int  valueToConvert 
)

Returns the given BCD value in Binary Format (RTC_B ONLY).

Parameters:
baseAddressis the base address of the RTC module.
valueToConvertis the raw value in BCD format to convert to Binary. Modified bits are BCD2BIN of BCD2BIN register.

This function converts BCD values to Binary format.

Returns:
The Binary version of the valueToConvert parameter.

References HWREG.

unsigned int RTC_convertBinaryToBCD ( unsigned int  baseAddress,
unsigned int  valueToConvert 
)

Returns the given Binary value in BCD Format (RTC_B ONLY).

Parameters:
baseAddressis the base address of the RTC module.
valueToConvertis the raw value in Binary format to convert to BCD. Modified bits are BIN2BCD of BIN2BCD register.

This function converts Binary values to BCD format.

Returns:
The BCD version of the valueToConvert parameter.

References HWREG.


Copyright 2012, Texas Instruments Incorporated