Proton BASIC Compiler - How to use DS1307 RTC

  • PicŪ Basic

  • How to use DS1307 RTC

    In basic code i am using shin & shout commands with DS1307. If you want to use DS1307 RTC in your project. Simple cut & paste this code. Using little change you can use same code for HT1380. DS1307 data sheet is available at maxim site & HT1380 data sheet is available at HOLTEK semiconductor.

    '************************************************* ***************
    '* 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
    DelayMS 100
    Print Cls,"RTC Display"
    DelayMS 1000
    Low rst 'reset rtc
    Low clk
    '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
    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
    Set rst 'ready for transforme
    SHOut dta,clk,lsbfirst,[$bf]
    SHIn dta,clk,lsbpre,[sec,mint,hour,date,month,day,year,control]
    Clear rst
    contributed by Roshan.
  • Recent Activity


    GPS speed logger for RC planes.

    Thread Starter: david

    Hi All, This is a simple project to allow the logging of RC plane speeds to help determine battery, motor and prop variables. The code is crude and...

    david Yesterday, 21:01 Go to last post

    Baud rate problem

    Thread Starter: charliecoultas

    I am trying to run one of the USARTs on a 24HJ128GP502 at 115,200 bits/second. I thought I had defined the clock frequency wrong but Delayms gives...

    Les Today, 17:06 Go to last post