'------------------------------------------------------------------------------- ' Name: RTC1_ALARM_DEMO.TIG ' Type: Tiger-BASIC(tm) Source Code ' Purpose: Demonstrate use of the Tiger's alarm pin ' ' (C) - Copyright Wilke Technology, P.O.Box 1727, D-52018 Aachen, Germany '------------------------------------------------------------------------------- ' ' Thank you for using BASIC Tigers in your products. If you have questions, ' ideas or special needs, please contact your next distributor or the Tiger ' support team and visit our web site: ' ' Wilke Technology GmbH ' The Tiger Support Team ' P.O.Box 1727, D-52018 Aachen, Germany ' Krefelder Str. 147, D-52070 Aachen, Germany ' ' email: support@wilke-technology.com (english) ' email: support@wilke.de (german) ' Phone: +49 (241) 918 900 Mo to Fr, 7:00 to 16:00 (GMT) ' Fax: +49 (241) 918 9044 ' ' New information, new drivers and free downloads see: ' ' www.wilke-technology.com (english) ' www.wilke.de (german) ' ' Sincerely, ' ' Your Tiger Support Team ' '------------------------------------------------------------------------------- ' ' This example program was compiled with Tiger-BASIC 5.01 to run on a ' BASIC-Tiger module with clock. Connect the alarm pin with a pullup-R to 5V. ' When alarm is set and activated, the alarm pin gets high, until alarm time ' has come. ' '------------------------------------------------------------------------------- #INCLUDE UFUNC3.INC ' User-Function-Codes TASK Main ' begin task MAIN LONG Seconds, Prev_Sec, AT, ADEL, TOGGLE ' declare LONG variables INSTALL_DEVICE #1, "LCD1.TDD" ' install LCD driver INSTALL_DEVICE #3, "RTC1.TDD" ' install RTC driver TOGGLE = 0 ' initialize toggle RTCSTAT = RTC_INITIAL ' initialize RTC status WHILE RTCSTAT < RTC_NO_RTC ' while RTC is searched GET #3, #0, #UFCI_RTC_STAT0, 1, RTCSTAT ' read status of clock PRINT #1,"<1>installing"; ' WAIT_DURATION 200 ' wait 200 ms ENDWHILE ' IF RTCSTAT = RTC_PRESENT THEN ' if RTC is present Seconds = 12345678 ' any value for seconds PUT #3, Seconds ' set clock to that value RTCSTAT = RTC_BUSY ' initialize RTC status WHILE RTCSTAT = RTC_BUSY ' while RTC is busy GET #3, #0, #UFCI_RTC_STAT1, 1, RTCSTAT ' read status of clock PRINT #1,"<1>busy"; ' WAIT_DURATION 200 ' wait 200 ms ENDWHILE ' LOOP 999999999 ' many many loops Prev_Sec = Seconds ' store old time value WHILE Seconds = Prev_Sec ' while new = old time GET #3,0, Seconds ' read clock ENDWHILE ' PRINT #1,"<1>RTC-Time =<0>";Seconds; ' if new time, show it on LCD IF TOGGLE = 0 THEN ' if toggle not set '------------------------------------------------------------------------------- ' Secondary address = 1 (set alarm time) '------------------------------------------------------------------------------- ' ' Alternatives for setting alarm time: ' ' a) Set alarm time only: ' ' PUT #RTC, AT ' AT = Byte, Word or LONG: 0 ... 2,xxx,xxx,xxx ' ' Sets the time at which alarm pin is set back to LOW ' ' ' b) Set alarm time & delay: ' 1. Give the alarm time itself ' 2. Give the delay, when the inactive period should start ' ' PUT #RTC, AT, ADEL ' ! ! ' ! !--- Byte, Word, Long: 0...60 ' ! ' !--- always LONG variable: 0...2,xxx,xxx,xxx ' '------------------------------------------------------------------------------- ADEL = 0 ' delay AT = Seconds + 100 ' alarm time PUT #3, #1, Seconds + 64, 32 ' set alarm time, delay ' PUT #3, #1, AT, ADEL ' set alarm time, delay TOGGLE = 1 ' Set toggle ENDIF IF TOGGLE = 1 THEN ' if toggle is set PRINT #1,"<27>A<0><3><240>Alarm is set" ' show when new time ENDIF ' ENDLOOP ' ELSE ' if no RTC present PRINT #1, "<1>No RTC found" ' ENDIF ' END ' end of task MAIN