HEX to DEC conversion question (BCD?)
As many of you know I have been working on updating my 16x16 tricolored LED Matrix RTC.
I have added a 74HC165 to my 16x16 tricolored LED Matrix RTC circuit because there was only 3 I/O lines left on my SX52 and I needed at least 4 pushbuttons to set the date and time on this.
However, as it stands at the moment I can increment and decrement a hex number on the display and even watch it scroll by while updating it. I'm not sure if I want to have it scroll while updating the time or date but for now it is ok.
The problem I need help in understanding or need a solution to is as follows:
If I start with a TIMESET = 34 variable declaration, the display routine keeps it in·hex so that·when incrementing the TIMESET variable it·gets displayed as 34 35 36 37 38 39 3A 3B ....
Currently I have tried JonnyMac's DEC2BCD routine which I have seen good results on in the past. However, in this application I don't know how to link them together right. I·have tried and only get the last digit scrolled like 4 5 6 7 8 9 A B ... so something on my end is not right.
What do I have to do to get past this·so that it gets incremented as 34 35 36 37 38 39 40 41 .. ?
I looks like I need to increment a decimal (or maybe BCD) number·but the display routine needs a hex number.
I have attached my code for anyone to follow.
Thanks.
Post Edited (T&E Engineer) : 5/18/2007 6:49:40 PM GMT
I have added a 74HC165 to my 16x16 tricolored LED Matrix RTC circuit because there was only 3 I/O lines left on my SX52 and I needed at least 4 pushbuttons to set the date and time on this.
However, as it stands at the moment I can increment and decrement a hex number on the display and even watch it scroll by while updating it. I'm not sure if I want to have it scroll while updating the time or date but for now it is ok.
The problem I need help in understanding or need a solution to is as follows:
If I start with a TIMESET = 34 variable declaration, the display routine keeps it in·hex so that·when incrementing the TIMESET variable it·gets displayed as 34 35 36 37 38 39 3A 3B ....
Currently I have tried JonnyMac's DEC2BCD routine which I have seen good results on in the past. However, in this application I don't know how to link them together right. I·have tried and only get the last digit scrolled like 4 5 6 7 8 9 A B ... so something on my end is not right.
What do I have to do to get past this·so that it gets incremented as 34 35 36 37 38 39 40 41 .. ?
I looks like I need to increment a decimal (or maybe BCD) number·but the display routine needs a hex number.
I have attached my code for anyone to follow.
Thanks.
Post Edited (T&E Engineer) : 5/18/2007 6:49:40 PM GMT
Comments
temp = timeSet AND $0F
IF temp = 9 THEN
· timeSet = timeSet + 7
ELSE
· INC timeSet
ENDIF
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
“The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.hittconsulting.com
·