A
ashu
dear all,
I am facing a compilation problem for my C code on a 8 bit micro
controller (Motorola HC11).
I use cosmic software's compiler which allows me to directly refrence
addresses, using the @ variable.
*****************************************************************************************************************
So the undermentioned C statement,
unsigned char portA @ 0xD300;
will enable me to use portA to access the memory location D300.
I can now read and write to the memory location D300 using simple C
statements like
portA= 10; (will write 10 at location D300 refrenced by portA)
similarly to read i can say....
c= portA; (this will copy the value inside memory location D300
referenced by variable portA to c).
*********************************************************************************************************************
Now the problem starts...
I made a declaration like this,
********************************************************************************************
unsigned char register_data @ 0x00FE; /* declare a register whose
address is 00FE*/
unsigned char *ptr_db;
unsigned char ram_packet_header @ 0xD300; /* declare a memory address,
0xD300*/
ptr_db = &ram_packet_header; /* Now ptr_db contains the address
D300*/
untill here therr is no problem and the code compiles fine.
Now I want to store the content of ptr_db( which is 0xD300, an
address) in the variable register_data. .
so I say,
register_data = (unsigned char) ptr_db;
which doesnt compile and gives me incompatible pointer type
assingment.
Is there a way to get the value stored inside a pointer type variable
(which is an address) and store it in another unsigned char variable ?
Thanks
ashu
I am facing a compilation problem for my C code on a 8 bit micro
controller (Motorola HC11).
I use cosmic software's compiler which allows me to directly refrence
addresses, using the @ variable.
*****************************************************************************************************************
So the undermentioned C statement,
unsigned char portA @ 0xD300;
will enable me to use portA to access the memory location D300.
I can now read and write to the memory location D300 using simple C
statements like
portA= 10; (will write 10 at location D300 refrenced by portA)
similarly to read i can say....
c= portA; (this will copy the value inside memory location D300
referenced by variable portA to c).
*********************************************************************************************************************
Now the problem starts...
I made a declaration like this,
********************************************************************************************
unsigned char register_data @ 0x00FE; /* declare a register whose
address is 00FE*/
unsigned char *ptr_db;
unsigned char ram_packet_header @ 0xD300; /* declare a memory address,
0xD300*/
ptr_db = &ram_packet_header; /* Now ptr_db contains the address
D300*/
untill here therr is no problem and the code compiles fine.
Now I want to store the content of ptr_db( which is 0xD300, an
address) in the variable register_data. .
so I say,
register_data = (unsigned char) ptr_db;
which doesnt compile and gives me incompatible pointer type
assingment.
Is there a way to get the value stored inside a pointer type variable
(which is an address) and store it in another unsigned char variable ?
Thanks
ashu