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
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;
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Far pointer is used to access memory locations outside the program.
Long time no C. I need to learn the language again.
Help a man when he is in trouble and he will remember you when he is in trouble again.
You learn in life when you lose.
Complex problems have simple, easy to understand wrong answers.
"A ship in the harbour is safe, but that's not what ships are built
for"
'far' is obsolete with the introduction of 32bit compilers. Oh, wait. That means at least 50% of the people here still use it.
Quzah.
Hope is the first step on the road to disappointment.
Z8 Zilog, I did try withOriginally Posted by Dave_Sinkulabut 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.Originally Posted by wolfsafety
But yes, your best bet would be getting support from the compiler vendor.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
Try it like the following:
Now dereference pREG like you would any other pointer.Code:#define pREG (volatile unsigned long*)0x0x3FF