Hi,
how do I access a memory locations in C? For example how do I read what is in memory at address 0x3FF?
Thanks
wolf
Printable View
Hi,
how do I access a memory locations in C? For example how do I read what is in memory at address 0x3FF?
Thanks
wolf
What embedded microcontroller are you using? Typically it would be done something like this.
But frequently registers of interest have #defines to make the syntax nicer looking.Code:unsigned char value = *(unsigned char *)0x3FF;
Far pointer is used to access memory locations outside the program.
'far' is obsolete with the introduction of 32bit compilers. Oh, wait. That means at least 50% of the people here still use it. :rolleyes:
Quzah.
Z8 Zilog, I did try withQuote:
Originally Posted by Dave_Sinkula
but I get the wrong value. I also tried what you suggeted but gives me a compiler error. I suppose that it is compiler dependent hence I will have to contact them to know how to do it.Code:#define MYVERSION (*(unsigned char volatile far*)0x3FF)
>I also tried what you suggeted but gives me a compiler error.
You probably need to break what Dave gave you into two lines, one for the declaration, and one for the assignment:
Code:unsigned char value; /* Place this with your other variable declarations */
value = *(unsigned char *)0x3FF;
I did a quick look at the Zilog site, but you didn't mention which micro so I picked one at random. I also looked at the ZDS manual, and it mentions that there are extensions for near, far, and rom pointers. Since I'm not familiar with your device, or even the Z8 for that matter, I'm hard-pressed to know in which address space 0x3FF might reside.Quote:
Originally Posted by wolfsafety
But yes, your best bet would be getting support from the compiler vendor.
Try it like the following:
Now dereference pREG like you would any other pointer.Code:#define pREG (volatile unsigned long*)0x0x3FF