Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8051 and external Flash memory using C?

Status
Not open for further replies.

ricepotato2006

Newbie level 4
Joined
Oct 12, 2009
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Taiwan
Activity points
1,312
Hi All,

I am trying to read and write to external memory.
and I want to read data from flash memory and output to P0

now I have a few questions.

1. do I need to set the ALE, EA, RD, and WR bits?
2. Following is my code, and it seem not to do anything, something wrong?



main()
{
xdata char xdata *a_Ptr=0x8000;
char myX;

while(1)
{
myX=*a_Ptr;
P0=myX;
}
}



Thank you in advance
 

Xdata access is supposed to work without additional setup, but you shouldn't place the pointer variable in xdata. Try
Code:
char xdata *a_Ptr=0x8000;
 
thanks for the replay,

I have tried your suggestion, and modified my code as follows


main()
{
char xdata *a_Ptr=0x8000;
char myX;

while(1)
{
for(i=0;i<=15;i++)
{
myX=*a_Ptr;
P0=myX;
}
}
}

since my flash memory already has data in it, I added a loop to try to read the data and output from P0, but the output is not the data in the flash memory. instead, it output the numbers from 0 to 15. what could be the problem?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top