Bcd Fomat Help


Closed Thread
Results 1 to 17 of 17

Thread: Bcd Fomat Help

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Bcd Fomat Help

    The Queen has not been here for awhile, but maybe this will help
    Code:
    READ_RTC:
        I2CREAD DS_SDA, DS_SCL, RTC, SEC_REG, [sec,mins,hr,day,date,mon,yr]
    
        SEC_T = sec & $70
        SEC_T = SEC_T>>4
        SEC_O = sec & $0F
    
        MIN_T = mins & $70
        MIN_T = MIN_T>>4
        MIN_O = MINs & $0F
    
        HR_T = hr & $70
        HR_T = HR_T>>4
        HR_O = hr & $0F
    
        MON_T = mon & $70
        MON_T = MON_T>>4
        MON_O = mon & $0F
    
        DATE_T = date & $70
        DATE_T = DATE_T>>4
        DATE_O = date & $0F
    
        YR_T = yr & $70
        YR_T = YR_T>>4
        YR_O = yr & $0F
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Nov 2012
    Posts
    3


    Did you find this post helpful? Yes | No

    Default Re: Bcd Fomat Help

    Quote Originally Posted by mackrackit View Post
    The Queen has not been here for awhile, but maybe this will help
    Code:
    READ_RTC:
        I2CREAD DS_SDA, DS_SCL, RTC, SEC_REG, [sec,mins,hr,day,date,mon,yr]
    
        SEC_T = sec & $70
        SEC_T = SEC_T>>4
        SEC_O = sec & $0F
    
        MIN_T = mins & $70
        MIN_T = MIN_T>>4
        MIN_O = MINs & $0F
    
        HR_T = hr & $70
        HR_T = HR_T>>4
        HR_O = hr & $0F
    
        MON_T = mon & $70
        MON_T = MON_T>>4
        MON_O = mon & $0F
    
        DATE_T = date & $70
        DATE_T = DATE_T>>4
        DATE_O = date & $0F
    
        YR_T = yr & $70
        YR_T = YR_T>>4
        YR_O = yr & $0F
    You have given RTC Read function. It used Bcd2Dec. I need Dec2Bcd for RTC Writing.

    is this RTC Read code correct
    Code:
     ssec = ((sec & 0x70) >> 4) + (sec & 0x0F)

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Bcd Fomat Help

    Quote Originally Posted by jayanthd View Post
    You have given RTC Read function. It used Bcd2Dec. I need Dec2Bcd for RTC Writing.

    is this RTC Read code correct
    Code:
     ssec = ((sec & 0x70) >> 4) + (sec & 0x0F)
    That will give you the ones place.

    From the manual
    4.17.7. DIG

    DIG returns the value of a decimal digit. Simply tell it the digit number (0 - 4 with 0 being the rightmost digit) you would like the value of, and voila.

    B0 = 123 ' Set B0 to 123
    B1 = B0 DIG 1 ' Sets B1 to 2 (digit 1 of 123)
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. DS1302 16F628 Woes
    By idtat in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th January 2009, 14:15
  2. BCD problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th September 2008, 16:36
  3. Rotary BCD
    By Tobias in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 03:04
  4. Real time clock... what a headache!
    By Eng4444 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 8th June 2006, 21:56
  5. Leading 0's or BCD
    By RYTECH in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 28th December 2005, 01:06

Members who have read this thread : 1

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

Posting Permissions

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