how to store a value at the specified location in RAM.
-
hello all, this requirement is for an embedded device. i need to use the memory available at a predefined address, say for example, 0xe000 2828 in RAM. so i need to define a variable some thing like int *i=0xe000 2828; i mean, here, 'i' should be mapped to the desired memory location. but syntactically, the above statement is wrong. i remember, this can be achieved using a far pointer. but iam unable to do this, and my compiler does not accept if i use as follows. int far *i=0xe000 2828; please suggest me the mechanism to achieve this. thanks in advance.
You should read the documentation of your (cross) compiler :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
You should read the documentation of your (cross) compiler :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]hai pallini, thanks for your response. yes, i have gone through that, but this specific point is not addressed properly in that. can you please suggest me any other clue. let me explain the issue a bit detailed. the document says that, the RAM available from that particular location up to 2k is battery backed up RAM. means, though the device is powered off, as long as the battery lives, the data written into that memory will be un lost. right, i think now, you might give me some clue. thank you.
-
hello all, this requirement is for an embedded device. i need to use the memory available at a predefined address, say for example, 0xe000 2828 in RAM. so i need to define a variable some thing like int *i=0xe000 2828; i mean, here, 'i' should be mapped to the desired memory location. but syntactically, the above statement is wrong. i remember, this can be achieved using a far pointer. but iam unable to do this, and my compiler does not accept if i use as follows. int far *i=0xe000 2828; please suggest me the mechanism to achieve this. thanks in advance.
Well, your compiler and package probably came with header files describing built in I/O ports - look at those for the syntax. But I'm sure what you wrote is wrong - I doubt the compiler will a space in the middle of a number. The last embedded work I did was on a 32bit processor, so it may be harder for you (in which case, read headers as above), but the following worked for me:
unsigned int *pSomewhere = (unsigned int *)0x12341234;
Obviously that's not the real name or number, but I hope you get the idea. You may just need the odd far. Iain.
-
hai pallini, thanks for your response. yes, i have gone through that, but this specific point is not addressed properly in that. can you please suggest me any other clue. let me explain the issue a bit detailed. the document says that, the RAM available from that particular location up to 2k is battery backed up RAM. means, though the device is powered off, as long as the battery lives, the data written into that memory will be un lost. right, i think now, you might give me some clue. thank you.
Well, I suppose the compire manual will tell you how to access the device address space. What device are dealing with? What compiler are you using? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Well, I suppose the compire manual will tell you how to access the device address space. What device are dealing with? What compiler are you using? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]the device is arm controller. and the compiler is provided by him. any way, i got a clue to use volatile int. this i got from one of the macros provided by him. let me try this out and i will announce it here if it is solved. thanks again for your support.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
-
Well, your compiler and package probably came with header files describing built in I/O ports - look at those for the syntax. But I'm sure what you wrote is wrong - I doubt the compiler will a space in the middle of a number. The last embedded work I did was on a 32bit processor, so it may be harder for you (in which case, read headers as above), but the following worked for me:
unsigned int *pSomewhere = (unsigned int *)0x12341234;
Obviously that's not the real name or number, but I hope you get the idea. You may just need the odd far. Iain.
yes, thanks for your response. the space, which you are talking about, i would have given it like that in forums but i gave it as a single value in my code. but still it wasnt working. any ways, iam trying to implement it using volatile. thanks all for your suggestions.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
-
yes, thanks for your response. the space, which you are talking about, i would have given it like that in forums but i gave it as a single value in my code. but still it wasnt working. any ways, iam trying to implement it using volatile. thanks all for your suggestions.
-------------------------------------------- Suggestion to the members: Please prefix your main thread subject with [SOLVED] if it is solved. thanks. chandu.
chandu004 wrote:
but still it wasnt working.
Without seeing your code, how you are using it, and what you are expecting instead, this is less than helpful.
chandu004 wrote:
iam trying to implement it using volatile.
Why?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
-
hello all, this requirement is for an embedded device. i need to use the memory available at a predefined address, say for example, 0xe000 2828 in RAM. so i need to define a variable some thing like int *i=0xe000 2828; i mean, here, 'i' should be mapped to the desired memory location. but syntactically, the above statement is wrong. i remember, this can be achieved using a far pointer. but iam unable to do this, and my compiler does not accept if i use as follows. int far *i=0xe000 2828; please suggest me the mechanism to achieve this. thanks in advance.
chandu004 wrote:
i need to use the memory available at a predefined address, say for example, 0xe000 2828 in RAM.
This is most likely a physical address and depending on what ARM architecture you're developing for, you may have an MMU[^] that maps physical addresses to virtual. This means you have to check your documentation for the following:
- Is your ARM architecture equipped with an MMU?
- If so, is it enabled?
- If 'yes', what API call are you supposed to make to read and write to and from physical addresses?
chandu004 wrote:
int *i=0xe000 2828;
Like Iain said, the compiler will swallow a type cast such as
int* pAddr = (int*)0xe0002828;
but depending on the MMU-stuff this will give you a virtual address which may not be what you need. The documentation for your compiler and your chip ought to have information about this. Finally: Your problem is very specific to your environment, so it's very hard to advise you to anything but reading the documentation for your compiler and the chipset you're using. You haven't even informed us what ARM architecture you are targeting. Also keep in mind that this forum is dedicated to developing windows applications with MFC and/or Win32 API, which is very different from developing for embedded systems. Of course you may be developing with Windows CE for embedded systems, but you haven't really said so clearly. If that's the case you may need to call ReadPhysical()[^] or WritePhysical()[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
hello all, this requirement is for an embedded device. i need to use the memory available at a predefined address, say for example, 0xe000 2828 in RAM. so i need to define a variable some thing like int *i=0xe000 2828; i mean, here, 'i' should be mapped to the desired memory location. but syntactically, the above statement is wrong. i remember, this can be achieved using a far pointer. but iam unable to do this, and my compiler does not accept if i use as follows. int far *i=0xe000 2828; please suggest me the mechanism to achieve this. thanks in advance.
To add to the previous answers, some embedded compilers have a non-standard
_at
extension that would enable you to do something like:int i _at(0xe0002828);
Otherwise, I would use something like:
int& i = *reinterpret_cast<int*> (0xe0002828);
-
chandu004 wrote:
but still it wasnt working.
Without seeing your code, how you are using it, and what you are expecting instead, this is less than helpful.
chandu004 wrote:
iam trying to implement it using volatile.
Why?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
DavidCrow wrote:
Why?
It probably points to a memory-mapped io register that gets changed by some hardware event.