Searching \ for '10 bit to BCD' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=bit+bcd
Search entire site for: '10 bit to BCD'.

Truncated match.
PICList Thread
'10 bit to BCD'
1995\08\21@110357 by Ross Lyle

flavicon
face
There has been a lot of discussion about BCD to Binary recently, but how
bout the other way.  The "Embedded Control Handbook", page 5-120 has a
16 bit to BCD listing but can take up to 885 clock cycles.  Anything more
efficient out there?  I need only a 10 bit to BCD routine (actually up to
999 ).

Ross Lyle
Camosun College
Victoria, BC
spam_OUTlyleTakeThisOuTspamcamosun.bc.ca

1995\08\21@184827 by Tim Braun

flavicon
face
> Date:         Mon, 21 Aug 1995 07:45:52 -0800
> From: Ross Lyle <.....LYLEKILLspamspam@spam@CAMADM.CAMOSUN.BC.CA>

> There has been a lot of discussion about BCD to Binary recently, but how
> bout the other way.  The "Embedded Control Handbook", page 5-120 has a
> 16 bit to BCD listing but can take up to 885 clock cycles.  Anything more
> efficient out there?  I need only a 10 bit to BCD routine (actually up to
> 999 ).

> Ross Lyle
> Victoria, BC         <--- hey, that's where my sisters live!

Well, I did a binary to bcd routine that handled up to 512.  You could
modify it to do 1024 without too much trouble, I suppose.  I used the
fact that x / 100 = (x/2) / 50, much like the BCD->binary routines.

Using (x/4) / 25 to generate the hundreds digit will allow eight bit
subtractive calculation.  Then you calculate (x/4 mod 25) * 4 + (x mod 4 )
and count the tens, leaving the ones.  I wasn't concerned about time
of execution, a millisecond wasn't a problem for me.  I was concerned
about RAM/ROM usage.

But I don't have the code handy.

Tim Braun                             | Voice: 204-942-2992 ext 228
Continental Healthcare Systems Canada | FAX:   204-942-3001
1900-155 Carlton St                   | Email: timspamKILLspamchs.mb.ca
Winnipeg, Manitoba, Canada R3C 3H8    | www: http://www.chs.mb.ca/~tim/home.html

More... (looser matching)
- Last day of these posts
- In 1995 , 1996 only
- Today
- New search...