All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Programmer's Corner

Notices

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.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 04-18-2011, 03:41 PM
RG23 RG23 is offline
Senior Member
 
Join Date: Dec 2010
Posts: 290
Default Hex to BCD conversion routine

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

Please let me know

Thanks
Reply With Quote
  #2  
Old 04-18-2011, 05:55 PM
RG23 RG23 is offline
Senior Member
 
Join Date: Dec 2010
Posts: 290
Default

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

What language are you using ?

Have you tried Google or Bing ?

Have you had a go yourself ?
Reply With Quote
  #4  
Old 04-18-2011, 06:54 PM
RG23 RG23 is offline
Senior Member
 
Join Date: Dec 2010
Posts: 290
Default

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
Reply With Quote
  #5  
Old 04-18-2011, 07:27 PM
Markd77's Avatar
Markd77 Markd77 is offline
Senior Member
 
Join Date: Sep 2009
Location: Birmingham
Posts: 2,782
Blog Entries: 1
Default

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.
http://www.piclist.com/techref/micro...adix/index.htm
Reply With Quote
  #6  
Old 04-18-2011, 07:35 PM
RG23 RG23 is offline
Senior Member
 
Join Date: Dec 2010
Posts: 290
Default

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
Reply With Quote
  #7  
Old 04-18-2011, 07:37 PM
RG23 RG23 is offline
Senior Member
 
Join Date: Dec 2010
Posts: 290
Default

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)
Reply With Quote
  #8  
Old 04-18-2011, 08:16 PM
RG23 RG23 is offline
Senior Member
 
Join Date: Dec 2010
Posts: 290
Default

i have still not figured it out

any help would be appreciated

Thanks
Reply With Quote
  #9  
Old 04-19-2011, 02:58 PM
RG23 RG23 is offline
Senior Member
 
Join Date: Dec 2010
Posts: 290
Default

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


Which unpacked bcd routine are you referring to?
Reply With Quote
  #10  
Old 04-19-2011, 05:11 PM
Markd77's Avatar
Markd77 Markd77 is offline
Senior Member
 
Join Date: Sep 2009
Location: Birmingham
Posts: 2,782
Blog Entries: 1
Default

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.
Reply With Quote
Reply   Post New Thread

Tags
, , ,


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compilation Error for Microchip IDE , C18 arikiev Embedded Systems and Microcontrollers 4 09-20-2010 08:32 PM
BCD to HEX in assembly Jefecito20 Programmer's Corner 1 05-06-2010 03:56 AM
PIC16f877- 16 bit hex to bcd converter amitesh Embedded Systems and Microcontrollers 1 03-01-2009 02:02 PM
8086 Microprocessor using Debug (hex to bin conversion) Reshma Programmer's Corner 6 12-19-2007 01:16 PM

Thread Tools
Display Modes

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 Jump


All times are GMT. The time now is 03:05 PM.


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License.
Powered by vBulletin
Copyright ©2000 - 2014, vBulletin Solutions, Inc.