[General] 2 byte Hex to BCD Conversion in C under keil

Status
Not open for further replies.

samskruthi

Newbie level 1
Joined
Jun 8, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
7
Hello friends

I am trying to convert 2 bytes hex value ( may be 0xa45) to bcd . but feeling difficult for the conversion during handling overflow. can u please any body suggest the logic of conversion . Please ping me back as soon as possible. thank you :-|.

I am able to perform 1 byte conversion as discussed in edaboard. please revert for 2 bytes conversion logic if any familiar with.
 

Code:
unsigned int uiValue = 0x202;
unsigned int uiResult = 0;

while (uiValue > 0) {
   uiResult <<= 4;
   uiResult |= uiValue % 10;
   uiValue /= 10;
}
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…