'************************************************* ***************
'* Name : DS1307 RTC.BAS *
'* Author : Roshan *
'* Notice : Copyright (c) 2005 *
'* : All Rights Reserved *
'* Date : 11/08/2005 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
Device 16F84A
XTAL 4
Config xt_osc,pwrte_off,wdt_off
'-----------------------------------------
Symbol rst PORTA.2
Symbol dta PORTA.0
Symbol clk PORTA.1
'-------------------------------
Declare LCD_TYPE 0
Declare LCD_DTPIN PORTB.0
Declare LCD_ENPIN PORTA.4
Declare LCD_RSPIN PORTA.3
Declare LCD_LINES 2
Declare LCD_INTERFACE 8
'---------------------------
Dim year As Byte
Dim day As Byte
Dim month As Byte
Dim date As Byte
Dim hour As Byte
Dim mint As Byte
Dim sec As Byte
Dim control As Byte
'--------------------------
TRISA=%00000000
DelayMS 100
Print Cls,"RTC Display"
DelayMS 1000
'--------------------------
Low rst 'reset rtc
Low clk
'-----------------------
year=05
day=3
month=8
date=15
hour=4
mint=0
sec=0
'----------------------
'set rtc with data
Set rst
SHOut dta,clk,lsbfirst,[$8e,0]
Clear rst
Set rst
SHOut dta,clk,lsbfirst,[$be,sec,mint,hour,date,month,day,year,0]
Clear rst
'-------------------------
loop:
GoSub get_time
Print Cls,DEC2 date,"/",DEC2 month,"/",DEC2 year
Print At 2,1,HEX2 hour,"/",HEX2 mint,"/",HEX2 sec
DelayMS 300
GoTo loop
'-------------------------
get_time:
Set rst 'ready for transforme
SHOut dta,clk,lsbfirst,[$bf]
SHIn dta,clk,lsbpre,[sec,mint,hour,date,month,day,year,control]
Clear rst
Return
'* Name : DS1307 RTC.BAS *
'* Author : Roshan *
'* Notice : Copyright (c) 2005 *
'* : All Rights Reserved *
'* Date : 11/08/2005 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
Device 16F84A
XTAL 4
Config xt_osc,pwrte_off,wdt_off
'-----------------------------------------
Symbol rst PORTA.2
Symbol dta PORTA.0
Symbol clk PORTA.1
'-------------------------------
Declare LCD_TYPE 0
Declare LCD_DTPIN PORTB.0
Declare LCD_ENPIN PORTA.4
Declare LCD_RSPIN PORTA.3
Declare LCD_LINES 2
Declare LCD_INTERFACE 8
'---------------------------
Dim year As Byte
Dim day As Byte
Dim month As Byte
Dim date As Byte
Dim hour As Byte
Dim mint As Byte
Dim sec As Byte
Dim control As Byte
'--------------------------
TRISA=%00000000
DelayMS 100
Print Cls,"RTC Display"
DelayMS 1000
'--------------------------
Low rst 'reset rtc
Low clk
'-----------------------
year=05
day=3
month=8
date=15
hour=4
mint=0
sec=0
'----------------------
'set rtc with data
Set rst
SHOut dta,clk,lsbfirst,[$8e,0]
Clear rst
Set rst
SHOut dta,clk,lsbfirst,[$be,sec,mint,hour,date,month,day,year,0]
Clear rst
'-------------------------
loop:
GoSub get_time
Print Cls,DEC2 date,"/",DEC2 month,"/",DEC2 year
Print At 2,1,HEX2 hour,"/",HEX2 mint,"/",HEX2 sec
DelayMS 300
GoTo loop
'-------------------------
get_time:
Set rst 'ready for transforme
SHOut dta,clk,lsbfirst,[$bf]
SHIn dta,clk,lsbpre,[sec,mint,hour,date,month,day,year,control]
Clear rst
Return


Menu
Recent Articles


Using PDS with SPI GLCD based on ST7565R Controller
Graphic LCDs based on the ST7565 are cheaper then GLCDs with other controllers. SPI requires only four pins. If the circuit