xdata unsigned long var_long _at_ 0x0150; unsigned char * pointer; pointer=0x0150; var_long=0x45213256; SBUF=*pointer; ... SBUF=*(pointer+1); ... SBUF=*(pointer+2); ... SBUF=*(pointer+3); ...
my uart communication work, when i send datas byte one byte. when i try to send a long variable in above form , uart com. dont work. is this format illegal? xdata unsigned long var_long _at_ 0x0150; unsigned char * pointer; pointer=0x0150; var_long=0x45213256;
*pointer : 0x45 ?? *(pointer+1) : 0x21 ?? *(pointer+2) : 0x32 ?? *(pointer+3) : 0x56 ??
You are assigning an integer to a generic pointer. I think you either need to make the pointer mspace specific or assign it thusly:
pointer = (unsigned char xdata *)0x0150;
Or just get rid of the "magic numbers" altogether and let the compiler do it for you:
pointer = &var_long;
that way you know it'll be right!
which is the alternative non-portable approach
Which is portable, and may be no less efficient...
View all questions in Keil forum