how to write data to code memory 8051

Status
Not open for further replies.

cheenu02

Junior Member level 3
Joined
Jun 16, 2011
Messages
31
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,500
hi,
I am trying to save my datas in the code memory of P89v51RD2 controller.I am using KEIL s/w.how to do it?
Help me..

thank you,
srinivasan
 

in C you can use the data type "code"

ex. unsigned char code a[10] = ....................
unsigned int code a=10 or strings can be passed using word code. it will go to you flash memory.
 

Hi,
I tried with that one But It is showing warning.
Below is my example program and warning displayed.
#include<p89v51rx2.h>
void main()
{
unsigned int code a=10;
while(1);
}
MEM_TEST.C(6): warning C280: 'a': unreferenced local variable

I want to assign the particular memory address in code memory and I want to read/write data from that memory area.
 

Declare the a outside the main function,
or make it a global variable it will work..

Example is shown below

#include<p89v51rx2.h>
unsigned int code a=10;
void main()
{

while(1);
}
 

while linking it is showing the following errors.Do I need to change any settings in KEIL compiler?

Build target 'Target 1'
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?CO?A
Program Size: data=9.0 xdata=0 code=19
"a" - 0 Error(s), 1 Warning(s).
 

Actually this warning occurs because you haven't used a in your program..
When you will use a no warning will appear..

#include<p89v51rx2.h>
unsigned int code a=10;
void main()
{
unsigned int i;
i = a;
while(1);
}

Hope this will work
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…