## display Hex as Dec using PIC16F84 series Microchip

## 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?

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

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