DS1302 demo question
Mikael S
Posts: 60
Hello,
In the DS1302 demo, the time is presented in the hour, minute and seconds variable. I want to display the numbers in that variables apart, for example 12 would be 1 and 2. How can i do this?
In the DS1302 demo, the time is presented in the hour, minute and seconds variable. I want to display the numbers in that variables apart, for example 12 would be 1 and 2. How can i do this?
Debug.str( SN.decx(hour,2)) Debug.str( string(":")) Debug.str( SN.decx(minute,2) ) Debug.str( string(":") ) Debug.str( SN.decx(second,2))
Comments
OOOOPPPSSS ERROR
Very simple, stupid me...
BCD is a compact form of reprsenting decimal values in a byte; each nibble can hold 0..99. If the code the Bruce showed you (which works for pure decimal values) returns unexpected results, you may have BCD and you can extract the digits with shifting and masking.
It seems to work fine, because the ds1302 return the time in a 2 digit format when in 24-h mode.
But i think i have the problem now, when i try do read a ds1620 and want the result in two separate digits. I have to study some shifting and masking....