Page 1 of 1

Bcd TO Decimal

Posted: Tue Mar 08, 2011 1:01 pm
by matthys
hi can anyone please assist me. i am doing a project where i'm reading an external rtcc via the i2c port. what is the easiest way to read the binary code decimal as decimal and not displaying 89sec instead of 59sec.
i will appreciate any help.

Re: Bcd TO Decimal

Posted: Tue Mar 08, 2011 3:09 pm
by medelec35
Hi matthys,

Try:
Decimal = (BCD >> 4)*10 + (BCD & 15)

Re: Bcd TO Decimal

Posted: Tue Mar 08, 2011 3:55 pm
by matthys
thank you very much i'll try it

Re: Bcd TO Decimal

Posted: Tue Mar 08, 2011 4:37 pm
by matthys
Hi Medelec35
Thanks a lot. I've tried it and it is successfull. :P

Re: Bcd TO Decimal

Posted: Tue Mar 08, 2011 5:04 pm
by medelec35
That's great!
Thanks for letting us know.