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 ZealandPosts: 35 |
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: AustraliaPosts: 6103 |
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 ZealandPosts: 711 |
' 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 |