PDA

View Full Version : Conversion Problem



Pesticida
- 18th March 2007, 09:27
Hi,

I have a little conversion Problem.

I have this:

ProjektSum var byte
Projeknumber var byte
LoopProjekt:
HSerin 30000,LoopProjekt,[Projeknumber[0],Projeknumber[1],Projeknumber[2],Projeknumber[3],Projeknumber[4],Projeknumber[5]]

My Input ist for example :9 5 0 6 6 2

then I have this:

'ProjektSum[0]= ((Projeknumber[0] - $30) * $A) + (Projeknumber[1] - $30)
'ProjektSum[1]= ((Projeknumber[2] - $30) * $A) + (Projeknumber[3] - $30)
'ProjektSum[2]= ((Projeknumber[4] - $30) * $A) + (Projeknumber[5] - $30)

I2CWrite sda,scl,%10100000,$F0,[ProjektSum[0],ProjektSum[1],ProjektSum[2]]

I want to write the first Byte as 95 the Seond one as 06 end the third as 62 but as decimal.My Problem is that the Number 65 was written as 5F and the third as 3E.
My question is how can I write this number in the EEprom as decimal.

Thank you very much for any Help.

Regard Pesti.

HenrikOlsson
- 18th March 2007, 10:25
Hi,
I'm not sure I understand the problem here. It's not a matter of how it's stored. It's a matter of how you display it when you retrieve it from the EEPROM. You say that the value 62 is stored as 3E but 3Ehex IS 62dec.

Sorry If I misunderstood the question.

/Henrik Olsson.

Pesticida
- 18th March 2007, 10:34
Hi,
Thanks for your interest.

I must to write my input 1:1 to my Eeprom Data example:

Hyperterminal Input : 9 5 0 6 6 2

EEprom Data : 95 06 62 ..........

I make a mistake i dont need decimal ,I think I must store this as hex 95,hex 06,hex 62 but idont know how i can convert this

Regard Pesti

Darrel Taylor
- 18th March 2007, 11:58
Hi Pesti,

Try this..
ProjektSum var byte[3]

LoopProjekt:
HSerin 30000,LoopProjekt,[HEX2 ProjektSum(0),HEX2 ProjektSum(1),HEX2 ProjektSum(2)]

I2CWrite sda,scl,%10100000,$F0,[ProjektSum(0),ProjektSum(1),ProjektSum(2)]

Pesticida
- 18th March 2007, 12:09
Hi,
Thank You very much! Taylor
:-) one little change and a so great solution.
Super.

Regard Pesti