I am using MC9S12DT128, 16 bit controller.I am trying to send a 32 bit data from one function to the other using 'void pointer'. But after passing the data to that function, i could see one of the three bytes missing. I even tried typecasting the variable while storing the data. Even then i could see one btye missing. Can you please suggest me a work around for this? Thanks.
Please find below the syntax of my code, var2 value shown in comment below is missing first byte. I cannot update
"Func1(void* var2)" as it is a production code.
Main.c:
Unsigned_32 var1;
var1= 0x12345600;
void main()
{
//var1 value here is 0x12345600
Func1(&var1);
}
Lib.h:
void Func1((void *) var2);
Lib.c:
void Func1(void* var2)
{
// var2 value seen here is 0x00345600
}
Your request is incomplete. Pointer to void can not be dereferenced. You need to typecast it first, and then dereference, or use memcpy like function. Your snippet is hiding important details. Also you didn't say what compiler you are uising.
The best would be to try reproducing problem in new blank project and show that project. If this is not feasible, then you should disassemble your sources and show relevant lines of asm code generated for var1= assignment, Func1() call and access to *var2 in Func1().