CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

16bit bin to BCD routine including combining to a 2 byte out

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
w2drz



Joined: 27 Dec 2006
Posts: 55
Location: Western New York - USA

View user's profile Send private message Visit poster's website

16bit bin to BCD routine including combining to a 2 byte out
PostPosted: Fri Dec 29, 2006 8:00 am     Reply with quote

Hi,
Here is a corrected rtn,

I forgot to clean up the listing before I sent it out.

Just so there is no confusion, works just as I needed for my program.

Using CCS 3.249
This version work great,
at this time have not seen problems that are in prior versions.

Thank you for the help to finish the project here.
tom


long Dig_0, Dig_1, Dig_2, Dig_3, Dig_4;

void bin_to_Dig(long bin_inp)
{ // This is for VK3UM program
long temp; // 16 bit binary to BCD 5 byte
int nibh;
int nibl;

temp = bin_inp / 18.2041667; // make into binary degrees value

Dig_4 = temp/10000;
temp = temp - (Dig_4 * 10000);

Dig_3 = temp/1000;

temp = temp - (Dig_3 * 1000);

Dig_2 = temp/100;
temp = temp - (Dig_2 * 100);

Dig_1 = temp/10;
temp = temp - (Dig_1 * 10);

Dig_0 = temp;

nibh = Dig_1; // MSB BYTE make ready to send out This is the 2nd digit
nibl = Dig_2; // LSB BYTE make ready to send out This is the 1st digit
CountMSB = (nibl|(nibh<<4));

nibh = Dig_3; // MSB BYTE make ready to send out This is the 3rd digit
nibl = Dig_0; // LSB BYTE make ready to send out is .1 value
CountLSB = (nibl|(nibh<<4));

}

Embarassed
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group