B4R Library DS3234 RTC

Discussion in 'B4R Libraries' started by kolbe, Jan 18, 2019.

Tags:
  1. kolbe

    kolbe Active Member Licensed User

    Here is a library using the SparkFun library for the DS3234 RTC.

    Code:
    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'Public variables can be accessed from all modules.
        Public Serial1 As Serial
        
    Public rtc As DS3234
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        
        
    'pin 5 For SPI CS
        rtc.Initialize(5)
        
        
    'set time in 24hr format
        rtc.SetTime1(0,22,23,2,14,1,19)
        
    'set to 12hr format
        rtc.Set12Hour(True)
        
        
    'Set alarm1
        rtc.Alarm1(0,45,14,18,False)
        
    'If alarm1 trips set interupt pin active
        rtc.AlarmInterrupt(True,False)
        
    'Check if alarm1 tripped and reset flag
        Log("Alarm tripped? ",rtc.AlarmStatus1(True))
        
        
    'Output a 1Hz square wave to interrupt pin
        rtc.EnableSQW(rtc.SQW_1Hz)
        
        
    'read SRAM location
        Log("sram 0x00: ",rtc.SRAMRead(0x00))
        
    'write SRAM location
        rtc.SRAMWrite(0x00,0xdd)
        
    'read SRAM location again
        Log("sram 0x00: ",rtc.SRAMRead(0x00))

        
    'Get time from RTC
        Log(rtc.Hour,":",rtc.Minute,":",rtc.Second," - ",rtc.Month,"/",rtc.Date,"/",rtc.Year)

    End Sub
     

    Attached Files:

    Beja, maXim, Mostez and 1 other person like this.
  2. Mostez

    Mostez Active Member

    great work
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice