• 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
    '--------------------------
    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
    contributed by Roshan.
  • Recent Activity

    See_Mos-247

    Mysterious PORTB problem

    Thread Starter: xldaedalus

    I'm using Proton+ to develop firmware for a product with switches. The MCU is an 18F26K22. Most of the switches reside on PORTB. I am NOT using a...

    See_Mos Today, 17:16 Go to last post
    joesaliba-353

    Watchdog timer

    Thread Starter: joesaliba

    I have a code that basically looks for four input and four outputs, depends on various timing and input conditions. I use interrupt and some delays...

    joesaliba Today, 12:10 Go to last post