Accessing hard coded memory locations using C

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing hard coded memory locations using C

4,055 Views
NeedHelp
Contributor I
Background:
The bootloader and OS are sharing the same UART and the OS needs to access some variables defined in the UART section of the bootloader.
Using the Keil compiler all I had to do was:
On the BL side:
unsigned int x _at_ SOME_HARD_CODED_VECTOR;
On the OS side:
unsigned int x _at_ SOME_HARD_CODED_VECTOR;
and both would essentially refer to the same address location.
 
However, code warrior doesnt support the _at_ keyword. How do I go about doing this in code warrior?
Basically how do I:
1. Define
int x;
int * y;
In the bootloader?
2. In such a way that I also have access to it from the OS? What would the code be in the OS side?
 
Please help! The datasheet shows accessing memory locations in assembly using P:$xxxx and D:$xxxx but how do I do it in C?
Thanks a bunch!
Labels (1)
Tags (1)
0 Kudos
Reply
5 Replies

1,196 Views
NeedHelp
Contributor I

Hi there!
I have yet another question:
How do I declare a "generic" pointer in codewarrior?
For example:
How should I declare
unsigned int * pTxData;
So that I can use it to point to data memory as well as program memory? Bare with me....

I have a macro:
#define  mPktSend(_cmd, _pdata, _size) {uTxCmd = _cmd; pTxData = _pdata; uTxCnt = _size;}

I want to be able to use this macro to send data both from data and program memory locations.
mPktSend(0x00, uPktTxBuf, 1); //uPktTxBuf is in data memory. Right now this works just fine.

And at the same time be able to use it as:
mPktSend(0x02, (__pmem unsigned int *)(uPrgmAddr), 16); //send 16 bytes from program memory location beginning in uPrgmAddr - declared as unsigned int uPrgmAddr;
Right now this gives me an error. Doesnt like the fact I am sending a __pmem location to the macro.

Thank you!

0 Kudos
Reply

1,196 Views
trytohelp
NXP Employee
NXP Employee
For this request I think it should be better we use the CRM system.
Please use Freescale on line support web page.
  - Go to following URL: http://www.freescale.com/TechSupport
  - Click on Submit a Service Request to create a new one or Manage Existing Service Request.
  - You will come to a login page.
  - You can submit your request through the web from there or view the activities of a SR.
In the Service Request can you please provide us some information:
 
details about the Tool version used.
To do that you must:
* CW:
Start the IDE and click on Help | About Metrowerks CodeWarrior.
Click on Installed Products 
Provide us all info displayed.
Or you can save them in a txt file.
 
Can you please provide us your example reproducing the issue ?
 
Regards
Pascal
0 Kudos
Reply

1,196 Views
NeedHelp
Contributor I
Thanks for the suggestion. I have done what you had told me to.
G'day.
0 Kudos
Reply

1,196 Views
trytohelp
NXP Employee
NXP Employee
Hi,
 
We don't support the same syntax.
See below extract of the 56800x_Build_Tools_Reference.pdf manual.
 
Specifying Variable Addresses in C
The user can tell the compiler to specify the address of a variable in a C file using the :
operator. The constant value following the : operator is the word address of the global
variable (i.e., int OneReg : 0xBCD ; specifies that the global variable OneReg
resides at word address 0xBCD).
 
 
Hope this will help you
Pascal
0 Kudos
Reply

1,196 Views
NeedHelp
Contributor I
Thanks a bunch! And thank god its friday!
0 Kudos
Reply