Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:51 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : write to DS3232 rtc with mmbasic

Author Message
banda
Newbie

Joined: 12/05/2014
Location: New Zealand
Posts: 35
Posted: 04:26pm 22 May 2014
Copy link to clipboard 
Print this post

I have had a great time learning from a series of posts in this forum dealing with the above series topic. There is a superb program written by JMAN that I am analysing
at the moment, but am not able to set up a breadboard for it yet.

In his coding he converts the secs, mins, etc to HEX before he writes them to the ds3232. I am under the belief that we must use BCD to write the time to the rtc.

Can JMAN or anyone else put my mind at rest?
It must be obvious that I'm a rank beginner.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6103
Posted: 05:28pm 22 May 2014
Copy link to clipboard 
Print this post

I don't have the code you are using to look at, but according to my reading of the datasheet, the DS3232 needs the time data in BCD as you thought.

Jim

VK7JH
MMedit   MMBasic Help
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 08:18pm 25 May 2014
Copy link to clipboard 
Print this post

  Quote  In his coding he converts the secs, mins, etc to HEX before he writes them to the ds3232. I am under the belief that we must use BCD to write the time to the rtc



' Convert to Hex
Sub BCDtoHex TempDec
hex = fix(tempdec / 10) * 16
hex = hex OR ((tempdec / 10) - (fix(tempdec / 10))) * 10
return

Hi

Would be better written as
Tempdec is your decimal value


'Convert Decimal to BCD
Sub DECtoBCD TempDec
BCD = fix(tempdec / 10) * 16
BCD = BCD OR ((tempdec / 10) - (fix(tempdec / 10))) * 10
return


So to convert normal decimal numbers to binary coded decimal
val is your decimal number

BCD=((val/10*16) + (val/10))


The original does indeed work just he labels are rather poor

Regards
Jman
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024