I need to convert 6-digit BCD to binary PICmicro

Thread Starter

atferrari

Joined Jan 6, 2004
4,069
All what I could find was conversion from 5-digits BCD to binary.

My maximum value (decimal) is 500000 (5E5) that is 6 digits.

No PIC list seems to have code for that.

Any help, anyone?

Gracias

Agustín Tomás
 

beenthere

Joined Apr 20, 2004
15,819
Hi,

Sounds like a number too large to fit the register length on a PIC. With 16 bits, the maximum value is 32768.

See if you can find a floating-point conversion routine for the PIC. That will let you compress the 6-digit decimal number into something the PIC can handle. Or so I hope - the number may still not go because it exceeds any register length that can do the floating-point conversion.
 

Thread Starter

atferrari

Joined Jan 6, 2004
4,069
6-digit BCD to three 8-bit bytes that is 24 bits. That's my intention. Don't worry if solution looks too much. If it works, it's OK for me.

Thanks for replying!!

Agustín Tomás
 

cyberhehe

Joined Oct 6, 2004
61
Originally posted by atferrari@Oct 18 2004, 05:08 AM
6-digit BCD to three 8-bit bytes that is 24 bits. That's my intention. Don't worry if solution looks too much. If it works, it's OK for me.

Thanks for replying!!

Agustín Tomás
[post=2966]Quoted post[/post]​

Will you tell me how you want your 6-digit BCD Data organized, i.e. each digit is placed into an 8-bit variable (which then consist of 6 Variables) where the LSByte points to the lower address, and MSB to the higher address). Also tell me how your result variables will be organized.
 

Thread Starter

atferrari

Joined Jan 6, 2004
4,069
Originally posted by cyberhehe@Oct 19 2004, 04:08 AM
how you want your 6-digit BCD Data organized,
Every BCD digit in one separate byte.

CMIL >> MSD
DMIL
UMIL
CENT
DECE
UNIT >> LSD

how your result variables will be organized
In three bytes, that is a 24-bits binary:

NROBIN_H
NROBIN_M
NROBIN_L

For these three, order is not relevant at all.

Thanks for your time and your help.

Agustín Tomás
 
Top