Y
Yodai
Hi all..
I'm trying to program an application for an emmbedded sistem where an
external processor introduces data into my RAM. The thing is some if the
data I have to pick up is written in hexadecimal format, but some other is
written on the memory positions in decimal format. How can I retrieve this
information reading it as decimal?
So far I use this:
#define MYHEXAVAR (uint_16t*(0x200))
//Which would allow me to read data from MYHEXAVAR just declaring it in my
function. Let's say the position 0x200 of my memory contains 0x0012 as a
value
void myfunc ()
{
sprintf(NewKey, "%3u", *MYHEXAVAR);
memcpy(Key, NewKey, 4);
}
or something similar, I've just outline the function because the real one is
much more complex and long and it wouldn't be good to make my point.
so this func would read memory position 0x200 and write the decimal
representation of 0x0012 which is "18". Now my problem is that I need it to
write "12"
Any of you guys have an idea to how to solve this problem.? It should be
fairly easy, but I don't know whats the easiest. I was thinking about doing
the whole conversion manually reading bit to bit, but I am sure there's some
other easier way....
Thanks in advance!
Marc
I'm trying to program an application for an emmbedded sistem where an
external processor introduces data into my RAM. The thing is some if the
data I have to pick up is written in hexadecimal format, but some other is
written on the memory positions in decimal format. How can I retrieve this
information reading it as decimal?
So far I use this:
#define MYHEXAVAR (uint_16t*(0x200))
//Which would allow me to read data from MYHEXAVAR just declaring it in my
function. Let's say the position 0x200 of my memory contains 0x0012 as a
value
void myfunc ()
{
sprintf(NewKey, "%3u", *MYHEXAVAR);
memcpy(Key, NewKey, 4);
}
or something similar, I've just outline the function because the real one is
much more complex and long and it wouldn't be good to make my point.
so this func would read memory position 0x200 and write the decimal
representation of 0x0012 which is "18". Now my problem is that I need it to
write "12"
Any of you guys have an idea to how to solve this problem.? It should be
fairly easy, but I don't know whats the easiest. I was thinking about doing
the whole conversion manually reading bit to bit, but I am sure there's some
other easier way....
Thanks in advance!
Marc