Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display Hex as Dec using PIC16F84 series Microchip

Status
Not open for further replies.

MrSteveMan

Technical User
Dec 26, 2000
6
0
0
US
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?
 
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
 
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}
 
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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top