Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

HOW TO CONVERT HEXA TO DECIMAL FOR LCD, PLS HELP!!!!!!!!

Status
Not open for further replies.

AUNG THANT

New Member
Hi,

I am Aung, from student of electronics engineering is singapore.

Now I am trying to do one program almost to finish, but I have a problem to convert Hexadecimal to Decimal from file register.

I needs to convert max H'FFFF' to Decimal, using PIC16f877.

I understands, there are two file registers for MSB and LSB since one file register can store only two hexadecimal H'FF'.

Pls help me to convert Hexa to Decimal;
Thank you very much.

With regard.

AMT,
amyothant@yahoo.com
 
Directly send it to register and read it out. It's read in both case of hexa or decimal. You don't have to convert it. Try with Nigel tutorial (see from his signature in this forum). He gave a wonderful workart to work with LCD displayer.

If you intend to do an convert algorithm get this.

f = 15 then you can compute by:

ffff = 15 ^ 4 + 15^3 + 15^2 + 15 = 65535

with 00c5 you will have:

0* 16^3 + 0* 16^2 + c*16^1 + 5*16^0 = 12 * 16 + 5 = 197

Is this what you need?
 
next3:
mov 38h,#30h
mov 39h,#30h
mov 3ah,#30h
mov 3bh,#30h
mov r0,spbylo
mov r1,spbyhi
inc r1 ;line 100
mov a,r0
jz next3a
inc r0
next3a: mov a,38h
inc a
mov 38h,a
clr c
subb a,#3ah
jc next3b
mov 38h,#30h
mov a,39h
inc a
mov 39h,a
clr c
subb a,#3ah
jc next3b
mov 39h,#30h
mov a,3ah
inc a
mov 3ah,a
clr c
subb a,#3ah
jc next3b
mov 3ah,#30h
mov a,3bh
inc a
mov 3bh,a
next3b: djnz r0,next3a
mov r0,#0ffh
djnz r1,next3a



--------------------
38h-3b h are locations where equvalent ascii values of corros dec no will b stored
byte hi n lo are hex nos to b converted
in lcd routine...u can ask to display contents of loc 38-3b h
 
mandar said:
next3:
mov 38h,#30h
mov 39h,#30h
mov 3ah,#30h
mov 3bh,#30h
mov r0,spbylo
mov r1,spbyhi
inc r1 ;line 100
mov a,r0
jz next3a
inc r0
next3a: mov a,38h
inc a
mov 38h,a
clr c
subb a,#3ah
jc next3b
mov 38h,#30h
mov a,39h
inc a
mov 39h,a
clr c
subb a,#3ah
jc next3b
mov 39h,#30h
mov a,3ah
inc a
mov 3ah,a
clr c
subb a,#3ah
jc next3b
mov 3ah,#30h
mov a,3bh
inc a
mov 3bh,a
next3b: djnz r0,next3a
mov r0,#0ffh
djnz r1,next3a



--------------------

doesn't seem like Pic16F877 Code to me... :lol:

Try the piclist for routines like this
www.piclist.com
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top