Exact match. Not showing close matches.
PICList
Thread
'[PIC]: Hi Tech BCD to Bin routine?'
2003\09\26@084707
by
?Graham=20North?=
Hi everyone,
Can someone help me by telling me how to convert BCD to Binary? I'm having a bad day! :-(
Cheers
Graham
---------------------------------
Want to chat instantly with your online friends? Get the FREE Yahoo!Messenger
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2003\09\26@085744
by
Vincent Vega
Try this: www.piclist.com/techref/microchip/math/radix/index.htm
I hope your day gets better, it's friday after all.
VV
Graham North <spam_OUTgraham_from_maltonTakeThisOuT
YAHOO.CO.UK> wrote:
Hi everyone,
Can someone help me by telling me how to convert BCD to Binary? I'm having a bad day! :-(
Cheers
Graham
---------------------------------
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2003\09\26@090700
by
hael Rigby-Jones
|
> -----Original Message-----
> From: Graham North [SMTP:.....graham_from_maltonKILLspam
@spam@YAHOO.CO.UK]
> Sent: Friday, September 26, 2003 1:46 PM
> To: PICLIST
KILLspamMITVMA.MIT.EDU
> Subject: [PIC]: Hi Tech BCD to Bin routine?
>
> Hi everyone,
>
> Can someone help me by telling me how to convert BCD to Binary? I'm having
> a bad day! :-(
>
> Cheers
>
> Graham
>
Is the BCD packed (i.e. two digits per byte) or unpacked (one digt per byte)
and how many digits?
The technique is very simple if you are not overly concerned about
efficiency (speed in this case).
unsigned int Bcd2Bin(unsigned int bcd)
{
// convert 4 digit packed BCD to binary
unsigned int bin;
bin= bcd & 0x000F; // get units
bdc >>= 4;
bin+= (bcd & 0x000F) * 10; // add tens
bdc >>= 4;
bin+= (bcd & 0x000F) * 100; // add hundreds
bdc >>= 4;
bin+= (bcd & 0x000F) * 1000; // add thousands
return bin;
}
This is as basic as it gets, you should be able to significantly speed this
up with a little thought. The method is the same for unpacked BCD, but
obviously you only have to deal with the lower nibble in each byte.
For some very fast methods check out the piclist web site. You will almost
certainly need to use inline assembly to use them however.
Mike
=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================
Any questions about Bookham's E-Mail service should be directed to
.....postmasterKILLspam
.....bookham.com.
--
http://www.piclist.com hint: The PICList is archived three different
ways. See http://www.piclist.com/#archives for details.
2003\09\30@050542
by
?Graham=20North?=
Thanks guys. I've got it sorted now.
My Friday got better, I worked on something different :-)
Graham
---------------------------------
Want to chat instantly with your online friends? Get the FREE Yahoo!Messenger
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics
More... (looser matching)
- Last day of these posts
- In 2003
, 2004 only
- Today
- New search...