All About Circuits Forum Hex to BCD conversion routine
 Register Blogs FAQ Members List Today's Posts Search Today's Posts Mark Forums Read

 Programmer's Corner Discussion forum for all aspects of programming and software engineering. Any software programming language welcome: C, C++, C#, Fortran, Java, Matlab, etc.

#1
04-18-2011, 03:41 PM
 RG23 Senior Member Join Date: Dec 2010 Posts: 290
Hex to BCD conversion routine

Does anyone have an idea about Hex to BCD conversion routine using pic?

Thanks
#2
04-18-2011, 05:55 PM
 RG23 Senior Member Join Date: Dec 2010 Posts: 290

Is there any subroutine available for converting hex to bcd?????
#3
04-18-2011, 06:51 PM
 DumboFixer Senior Member Join Date: Feb 2009 Location: South East UK Posts: 205

What language are you using ?

Have you tried Google or Bing ?

Have you had a go yourself ?
#4
04-18-2011, 06:54 PM
 RG23 Senior Member Join Date: Dec 2010 Posts: 290

i am using assembly language in pic

I tried google but didn't get any satisfying results

If you have any idea please let me know

Thanks
#5
04-18-2011, 07:27 PM
 Markd77 Senior Member Join Date: Sep 2009 Location: Birmingham Posts: 2,792 Blog Entries: 1

By hex do you mean a natural number stored in a register (or registers)? If so this should help. If you are not worried about memory, the unpacked BCD is easier to work with.
#6
04-18-2011, 07:35 PM
 RG23 Senior Member Join Date: Dec 2010 Posts: 290

Unpacked BCD to 16 bit binary conversion by Nikolai Golovchenko

but using the above I would get binary result

i am getting the correct frequency but its in hex format

so i first need to convert hex to bcd

i have bcd to ascii subroutine to display on LCD

Thanks
#7
04-18-2011, 07:37 PM
 RG23 Senior Member Join Date: Dec 2010 Posts: 290

At present when i divide 0x64 (decimal 100) by 0x21 (decimal 33)

I get 3.07 on LCD which is hex but i want to see 3.03 (decimal)
#8
04-18-2011, 08:16 PM
 RG23 Senior Member Join Date: Dec 2010 Posts: 290

i have still not figured it out

any help would be appreciated

Thanks
#9
04-19-2011, 02:58 PM
 RG23 Senior Member Join Date: Dec 2010 Posts: 290

If you are not worried about memory, the unpacked BCD is easier to work with.

Which unpacked bcd routine are you referring to?
#10
04-19-2011, 05:11 PM
 Markd77 Senior Member Join Date: Sep 2009 Location: Birmingham Posts: 2,792 Blog Entries: 1

I meant one of the binary to unpacked BCD links.
Unpacked stores each BCD digit in a byte, but packed stores 2 BCD digits in each byte.
eg. 93 is stored as b'10010011' in packed but as b'00001001' and b'00000011' in unpacked.

I think we need to see your code to be more help.

 Tags bcd, conversion, hex, routine

 Related Site Pages Section Title Worksheet Microcontroller principles Worksheet Digital codes Worksheet Numeration systems

 Similar Threads Thread Thread Starter Forum Replies Last Post arikiev Embedded Systems and Microcontrollers 4 09-20-2010 08:32 PM Jefecito20 Programmer's Corner 1 05-06-2010 03:56 AM amitesh Embedded Systems and Microcontrollers 1 03-01-2009 02:02 PM Reshma Programmer's Corner 6 12-19-2007 01:16 PM

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Electronics Forums     General Electronics Chat     The Projects Forum     Homework Help     Electronics Resources Software, Microcomputing, and Communications Forums     Programmer's Corner     Embedded Systems and Microcontrollers     Computing and Networks     Radio and Communications Circuits and Projects     The Completed Projects Collection Abstract Forums     Math     Physics     General Science All About Circuits Commmunity Forums     Off-Topic     The Flea Market     Feedback and Suggestions

All times are GMT. The time now is 12:50 PM.