Hi,
I don't use ASKII code for numbers
Your code says different!
With the SPRINTF you surely generate ASCII code. That´s the job of SPRINTF, It generates printable (human readable) characters.
***
and regarding the "mathematical operation" problems....
you need to know (as already mentioned)
* the type and range of your input value (you store in "key")
* and read all library documentations, especially on data types and ranges
No one can do this for you. We simply don´t have the informations.
You need to give use these informations to enable us to help you.
***
In any case, as soon as you transfer multi_byte informations you need to use some technique to ensure proper alignment at the receiver side.
Let´s say you have an UINT16 range (0...65535 decimal = 0x0000 to 0xFFFFF)
Now let´s say you want to transferthese values: 0x1234, 0x2A45, 0x63C8, 0x8254, 0xE589, ..
Then the bytewise datastream via the interface looks like this(assuming HIGH byte first): 0x12, 0x34, 0x2A, 0x45, 0x63, 0xC8, 0x82, 0x54, 0xE5, 0x89 ...
Even if you power up both devices at exactly the same time .. it may be that the receiver is a bit slower to boot and thus misses the first byte.
Then the receiver sees: 0x34, 0x2A, 0x45, 0x63, 0xC8, 0x82, 0x54, 0xE5, 0x89 ...
How do you know which byte is the HIGH byte and which is the LOW byte of the 16 bit variable? Impossible
you always need something like this:
0x34, [?], 0x2A, 0x45,[?], 0x63, 0xC8,[?], 0x82, 0x54,[?], 0xE5, 0x89,[?], ...
the [?] may be a gap in time, or a special byte or any other coding technique.. but it needs to be defined. Defined by you.
Klaus