Component: Real Time Clock (RTC) (Storage)
Author | Matrix TSL |
Version | 2.0 (Release) |
Category | Storage |
Contents
- 1 Real Time Clock (RTC) component
- 2 Examples
- 3 Downloadable macro reference
- 3.1 SetSecs
- 3.2 SetYear
- 3.3 GetDateString
- 3.4 SQWandINTcontrol
- 3.5 GetHours
- 3.6 GetSecs
- 3.7 GetYear
- 3.8 GetWeekDay
- 3.9 SetRamDS1307
- 3.10 SetWeekDay
- 3.11 SetMonth
- 3.12 SetHours
- 3.13 SetMins
- 3.14 GetMins
- 3.15 SetDate
- 3.16 GetTimeString
- 3.17 GetAmPm
- 3.18 GetDate
- 3.19 GetRamDS1307
- 3.20 GetMonth
- 3.21 Initialise
- 4 Simulation macro reference
- 5 Property reference
Real Time Clock (RTC) component
A Real Time Clock component allowing things like clocks and timers to easily be created. Compatible with the internal RTCC module and external DS1307 or DS3231 RTC ICs.
Examples
No additional examples
Downloadable macro reference
SetSecs
Sets the seconds as a binary value 0-59.
Does not currently simulate.
Parameters
- BYTE Seconds
- Range 0-59
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231
Return value
- This call does not return a value
SetYear
Sets the year as a binary value 0-99.
Does not currently simulate.
Parameters
- BYTE year
- Range 0-99
Return value
- This call does not return a value
GetDateString
Reads the current date from the RTC and returns it formatted as a string.
e.g. DD:MM:YY
Parameters
- BYTE USformat
- 0="DD/MM/YY", 1="MM/DD/YY"
Return value
SQWandINTcontrol
Allows a square wave output to be generated by the DS1307 and DS3231 ICs.
Also allows the DS3231 interrupts to be configured via the INT/SQW pin.
This function doesn't currently simulate.
Parameters
- BYTE SquareWaveEnable
- 0 = Square Wave Output Disabled / 1 = Square Wave Output Enabled
- BYTE FrequencySelect
- Controls the output frequency of the square wave, Range 0-3, Refer to the device datasheet for frequencies
- BYTE InterruptEnable
- Only Available on DS3231 and when SQW is disabled. Range 0-3
Return value
- This call does not return a value
GetHours
Gets the hours of the current time as a binary value 0-11 or 0-23.
Simulation returns system time.
Parameters
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231, 2=Alarm2 DS3231
Return value
GetSecs
Gets the seconds of the current time as a binary value 0-59.
Simulation returns system time.
Parameters
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231
Return value
GetYear
Gets the year as a binary value 0-99.
Simulation returns system date.
Parameters
- This macro has no parameters
Return value
GetWeekDay
Gets the day of the week as a binary value 1-7.
This function doesn't currently simulate.
Parameters
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231, 2=Alarm2 DS3231
Return value
SetRamDS1307
Sets the value of one of the free RAM locations on the DS1307 device
Parameters
- BYTE Address
- 56 RAM Locations. Range: 0 to 55
- BYTE Data
- Data value. Range 0 to 255
Return value
- This call does not return a value
SetWeekDay
Sets the day of the week as a binary value 1-7.
This function doesn't currently simulate.
Parameters
- BYTE Day
- Range 1-7
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231, 2=Alarm2 DS3231
Return value
- This call does not return a value
SetMonth
Sets the month as a binary value 1-12.
Does not currently simulate.
Parameters
- BYTE month
- Range 1-12
Return value
- This call does not return a value
SetHours
Sets the hours as a binary value 0-23.
Does not currently simulate.
Parameters
- BYTE Hours
- Range 0-23
- BYTE Mode
- 0=24 Hour Clock, 1=12 Hour Clock
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231, 2=Alarm2 DS3231
Return value
- This call does not return a value
SetMins
Sets the minutes as a binary value 0-59.
Does not currently simulate.
Parameters
- BYTE Minutes
- Range 0-59
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231, 2=Alarm2 DS3231
Return value
- This call does not return a value
GetMins
Gets the minutes of the current time as a binary value 0-59.
Simulation returns system time.
Parameters
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231, 2=Alarm2 DS3231
Return value
SetDate
Sets the date as a binary value 1-31.
Does not currently simulate.
Parameters
- BYTE date
- Range 1-31
Return value
- This call does not return a value
GetTimeString
Reads the current time from the RTC and returns it formatted as a string.
e.g. HH:MM:SS
Parameters
- BYTE IncludeSeconds
- 0=Dont Include Seconds, 1=Include Seconds
Return value
GetAmPm
Checks to see if the time is currently AM or PM for 12 hour clock mode.
Simulation returns system time.
0 = AM / 1 = PM
Parameters
- BYTE WhichClock
- 0=Time, 1=Alarm1 DS3231, 2=Alarm2 DS3231
Return value
GetDate
Gets the date as a binary value 1-31.
Simulation returns system date.
Parameters
- This macro has no parameters
Return value
GetRamDS1307
Gets a byte of RAM from the free memory on the DS1307 device.
Parameters
- BYTE Address
- 56 RAM Locations. Range: 0 to 55
Return value
GetMonth
Gets the month as a binary value 1-12.
Simulation returns system date.
Parameters
- This macro has no parameters
Return value
Initialise
Initialises the RTC component ready for operation.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
This component does not contain any simulation macros
Property reference
RTC Module
This property is of type Fixed list of ints and can be referenced with the variable name RTCModule.
No additional information
I2C Address
This property is of type Unsigned integer and can be referenced with the variable name I2CAddr.
No additional information
Channel
This property is of type Fixed list of ints and can be referenced with the variable name cal_i2c1::CHANNEL.
Channel selection
SDA
This property is of type Single digital pin and can be referenced with the variable name cal_i2c1::SDA.
Pin used for SDA (data signal)
SCL
This property is of type Single digital pin and can be referenced with the variable name cal_i2c1::SCL.
Pin used for SCL (clock signal)
Baud Select
This property is of type Fixed list of ints and can be referenced with the variable name cal_i2c1::BAUD_LIST.
Baud rate option selector
Baud Rate
This property is of type Signed integer and can be referenced with the variable name cal_i2c1::BAUD.
Baud rate to be used
Stop Delay
This property is of type True or false and can be referenced with the variable name cal_i2c1::StopDel.
On older microcontroller devices there is a potential for the I2C hardware channel to lock up if there is not
a 10ms delay between an I2C stop event and the next I2C start event.
Most modern microcontrollers will not have a problem so this property can be disabled to speed up the
I2C communications.
Clock Source
This property is of type Fixed list of ints and can be referenced with the variable name ClockSource.
No additional information