• 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

    kbaykar-24295

    Fault in bit wise comparisons on release 3.6.1.2.

    Thread Starter: kbaykar

    Hi Les, I just downloaded the release 3.6.1.2 today and seeing that it supports 18F47K40. I am trying to port my code from 18F4685 to 18F47K40. ...

    kbaykar Today, 17:26 Go to last post
    John Drew-26

    About Define directive...

    Thread Starter: SELCUK

    Hi Les, Thank you for new version of Proton Plus. For both Compiler version 3.6.1.1 and 3.6.1.2 If I define $DEFINE FF $0C ;// Form...

    John Drew Today, 02:10 Go to last post
    towlerg-21522

    Num_Byte on 18F26K42

    Thread Starter: towlerg

    I'm using a macro that was created by the generator Dump Macro P1 #if (Prm_Count > 1) #error "Dump - Too many parameters" #else ...

    towlerg Today, 19:20 Go to last post
    normnet-324

    Update path?

    Thread Starter: normnet

    I am currently running Proton v3.6.0.2 and would like to update to the latest version. Can i install the latest Update v3.6.1.2 on top of my...

    normnet Today, 14:41 Go to last post