I am trying to send info to set a RTC.
I understand I need to convert the received data, which is in hex format to BCD format to put into the RTC registers. Things are OK up to integer 15 (because everything is in the low nibble?), but when I try to convert integer 16 I get 10. It appears to me that everytime you get a "carry" into the high nibble you will have to do something "tricky" with the low nibble. Tricky = lookup table or recursive algorithm??
I have searched for hex to bcd conversion programs, but they seem to be way over the top for just changing an integer of max value 59 to BCD format.
Changing from BCD format to hex was easy to do, but I just can't work out how to do it the other way :(
Thanks for any "pointers".