DS1302 ask for and input load chip


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2017
    Location
    LAS VEGAS NV
    Posts
    2

    Default DS1302 ask for and input load chip

    All my code works but how do I substitute $30 with my TEMP

    one of my request to get start information:

    SEROUT2 TX, baudrate, ["ENTER HOUR (HH):",13]
    SERIN2 RX, Baudrate, [DEC2 TEMP]

    writing it to the ds1302:

    HIGH RST ' Activate the DS1302
    SHIFTOUT DG, CLK, 0, [$84] ' Send write hour
    SHIFTOUT DG, CLK, 0, [$30] ' Send hours
    LOW RST
    tried a lot of different solutions , but none worked
    thanks for the any help
    Robb

  2. #2
    Join Date
    Nov 2017
    Location
    LAS VEGAS NV
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: DS1302 ask for and input load chip

    thanks to Jamie s This works
    SEROUT2 TX, baudrate, ["ENTER HOUR (HH):",13]
    SERIN2 RX, Baudrate, [DEC2 TEMP]
    RTCHH=TEMP DIG 1
    RTCHH=RTCHH<<4
    RTCHH=RTCHH+(TEMP DIG 0)


    'writing it to the ds1302:
    HIGH RST ' Activate the DS1302
    SHIFTOUT DG, CLK, 0, [$84] ' Send write hour
    SHIFTOUT DG, CLK, 0, [RTCHH] ' Send hours
    LOW RST

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: DS1302 ask for and input load chip

    I believe you need to treat the data as Binary Coded Decimal, However if you enter the data as 2 digits of hexadecimal that should work. Just don't enter any alpha digits, ie. ABCDE or F. Try replacing the lines:

    SERIN2 RX, Baudrate, [DEC2 TEMP] with SERIN2 RX, Baudrate, [HEX2 TEMP]

    and

    SHIFTOUT DG, CLK, 0, [$30] ' Send hours with SHIFTOUT DG, CLK, 0, [HEX2 TEMP] ' Send hours
    Last edited by Dave; - 20th December 2017 at 15:04.
    Dave Purola,
    N8NTA
    EN82fn

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,381


    Did you find this post helpful? Yes | No

    Default Re: DS1302 ask for and input load chip

    Quote Originally Posted by Dave View Post

    SHIFTOUT DG, CLK, 0, [HEX2 TEMP] ' Send hours
    will not work

    the value needed to be sent is a packed bcd byte not two hex chrs
    consideration also of the 12/24 hour bit must be considered also


    simple way to convert binary hour value in tmp to packed bcd in hour

    HOUR = ((tmp / 10) << 4) + (tmp // 10) ; bin to bcd
    Last edited by richard; - 20th December 2017 at 22:56.
    Warning I'm not a teacher

Similar Threads

  1. Replies: 8
    Last Post: - 22nd January 2016, 19:27
  2. DS1302 Problem, again :(
    By CuriousOne in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th May 2014, 11:34
  3. Can you use the same pin as input/output and control led load?
    By FromTheCockpit in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 15th August 2013, 10:28
  4. DS1302 and 18F452
    By Astro in forum mel PIC BASIC
    Replies: 2
    Last Post: - 9th May 2006, 23:02
  5. Ds1302
    By willie in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd October 2005, 19:04

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts