×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# display Hex as Dec using PIC16F84 series Microchip

 Forum Search FAQs Links MVPs

## display Hex as Dec using PIC16F84 series Microchip

(OP)
Hi,
Im trying to display a number stored in a register (as hex of course) of a PIC16F84 series microcontroller on a 7-segmented LED display as decimal.  Im presented with the problem of converting that number to dec and displaying it.  I am fairly new to the language.  Any helpful tips?

### RE: display Hex as Dec using PIC16F84 series Microchip

I haven't played around with the PIC microcontroller, but I've heard it doesn't have a divide operand. So... This is how I would do it:

check the register, and if it is greater than 100, subtract 100 from register until it is less than 100. count how many times you do the subtraction. This will be your 100's digit.

THEN:

check the register, and if it is greater than 10, subtract 10 from register until it is less than 10. count how many times you do the subtraction. This will be your 10's digit.

THEN:
The number remaining in the register is your 1's digit.

Use a lookup table to convert the 100's, 10's & 1's digits into seven segment codes to send to the IO ports to which you hopefully have a 3 digit seven segment display attached.

Kim_Christensen@telus.net
http://www3.bc.sympatico.ca/Kim_Christensen/index.html

### RE: display Hex as Dec using PIC16F84 series Microchip

Do not think that mentioning what chip you have is edaquate to the problem.Usually,people who are trying to convert a number to another number system they follow this algorithm:

{ In your case from hex to dec }

1) Take a number and divide it by the base value of the number system you want it to be converted into.
2) To remainder you should should add 30h,so it will represent a char that corresponds to the remainder.
3) The integer part after division should be divided again,until you have 0.
4) All chars might be stored in a string,but displayed backwards.

Best Regards,

aphrodita@mail.krovatka.ru     {uiuc rules}
http://www.hellforge.org

### RE: display Hex as Dec using PIC16F84 series Microchip

(OP)
zBuilder, you were right there is no divide operand for this microcontroller.  Im still working on the details, but so far, your method seems to work good. Thanks!

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

#### Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!