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.

Using 8051 Von-Neumann memory

Status
Not open for further replies.

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Hi,

May i know what is von-Neumann memory at 0xE000?

What does it mean in the attached code? How can i apply the code? Currently i have a board which is c52 interface to external SRAM 62256.

Please advice.

Thank you.
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,435
Re: 8051_vonneumann

All depends on how the external SRAM is mapped, what address area it occupies ..

If you have PSEN and RD connected to an AND gate and then connected to the RD/ pin of the SRAM you can, using von Neumann concept where a single block of memory may be mapped to act as both data and program memory (This is referred to as the Von Neumann architecture), upload and then execute code from SRAM as well as keep data in it ..
By adopting the Von Neumann architecture, code may be written to memory as data bytes (MOVX), and then executed as program instructions ..

For example, if your SRAM is located at E000h you can do this:
LJMP E000h
And code execution will continue from SRAM ..

Rgds,
IanP

BTW couldn’t read your attachment ..
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

Thank for your reply. Sorry, just now is .zip attach file. Now i changed it to .rar file. The attachment is the coding which is using Keil compiler. Please try download again..If still can't read the attachment please let me know again..

Ya, you are rite. You are explain similar to my attached file. But how can i apply this method? Yes, my c52 /PSEN and /RD is connecting to AND gate and output to SRAM 62256. How can i do some practical on that? May i know in which situation we can use this method? Please you list out few example.. The sample code say is for debuger to simulate the hardware configuration! What does it mean?

Thank you.
 

IanP

Advanced Member level 5
Joined
Oct 5, 2004
Messages
7,942
Helped
2,309
Reputation
4,620
Reaction score
531
Trophy points
1,393
Location
West Coast
Activity points
66,435
Re: 8051_vonneumann

In the olden days when microcontrollers didn’t have FLASH, codes were stored in OTP or expensive EPROMS, so having available RAM to store code in and execute it from there while testing was very practical ..

Today's micros not only have quite a lot of program and data memories but can be re-programmed (in-system or in a programmer) for many times, so the concept of simulating the target code in a simulator (8051+SRAM) has not so many advantages ..

But, still, you can do it, specially if you use software debug MONITOR program such as this one:
https://www.keil.com/c51/mon51.asp
It looks like you can use it in your system as it is ..

You will be able to communicate with the 8051 using HYPERTERMINAL and selected keys from the PC’s keyboard, including uploading HEX files from PC to SRAM via serial port and C52 ..

Rgds,
IanP
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

I'm back to this topic.

Currently i have success download the hex data to 64kB SRAM and running the program. Now I would like to save the CODE data on external eeprom whenever power is ON will automatically download the data to SRAM and start running the program without manualy set the /EA to GND.

I'm understand how the does Von Neumann architecture work. A single block of memory may mapped to act as both data and program memory.

So, i would like to run my uC external memory as Von Neumann architecture but how the external SRAM map?

Currently, I have one program will write to external memory. The size mapped
Off-chip Code Memory: start = 0x0000, size = 0x4FFF
Off-chip Xdata memory: start = 0x5000, size = 0xAFFF

So, my CODE size will be is 0x5000, and the Xdata size is AFFF.

How can i make use of this 8051 von Neumann Memory method to access my external memory?

Code:
void main (void)
{
load_vonNeumann_memory ();                // Load VN memory

((void (code *) (void)) 0x0000) ();       // Call function in VN memory

while (1)                                 // Loop Forever
  {
  }
}

May i know this load_vonNeumann_memory (); function will be the download hex data to SRAM portion. The next ((void (code *) (void)) 0x0000) (); function will be the external CODE execution start at 0x0000 address. Am i rite?

I reallize when i apply this ((void (code *) (void)) 0x0000) (); function this function will point to the internal code address 0x0000. The pointer look like not pointed to external memory. So, whenever the function is point the coding will start at main() function again. Look like reset the coding.

Please guide me....

Thank you.
 

laktronics

Banned
Joined
Jan 6, 2007
Messages
943
Helped
176
Reputation
352
Reaction score
18
Trophy points
1,298
Activity points
0
Re: 8051_vonneumann

Hi,
Without using a switch, you can pull up EA- to Vcc, and use the internal flash of 8k along with an external code memory. The external code memory may be placed in the address space of 00 to 32k, but the initial 8k space will not be available. Your initial 8k including the bootloader program can be kept in the internal flash memory and the program will automatically continue with external code memory after 8k address. Alternatively, you store only bootloader in the internal memory and use the 24k upper address of the external memory for program and you make a jump to 8k+ external address to go to your external program from bootloader program.

You can use the upper 32k address space for data RAM and it you want more RAM, use a port bit and select another 64k space for external RAM.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

Thank for your reply.

The external code memory may be placed in the address space of 00 to 32k, but the initial 8k space will not be available.

There is the 3 part's i need to set which is Target "Off-Chip", C51 "Interrupt vector at address" and STARTUP.A51 line-125. The picture show the external code mapping configuration. Is it correct?

Your initial 8k including the bootloader program can be kept in the internal flash memory and the program will automatically continue with external code memory after 8k address.
What should i set to make the internal flash memory beyond 8k address will automatically continue run external code?

Code:
Alternatively, you store only bootloader in the internal memory and use the 24k upper address of the external memory for program and you make a jump to 8k+ external address to go to your external program from bootloader program.
Is it this option will be write the application program with included bootloader program? Just have to make a jump out the address 8k from internal flash memory to run external memory, am i rite?

If i would like to map my memory as 46kB for CODE, 10kB for XDATA and 8kB is for memory offset for internal flash memory. How can i set this configuration?

Thank you.
 

laktronics

Banned
Joined
Jan 6, 2007
Messages
943
Helped
176
Reputation
352
Reaction score
18
Trophy points
1,298
Activity points
0
Re: 8051_vonneumann

Hi,
There is really speaking no hard and fast rule regarding assignment of memory space, my suggestion was keeping in mind availability of memory chips and address decoding convenience so that address areas of external code and data do not overlap, since you are using WR signal for bootloading in the code area.

Yes, you do not have to worry about switching the program to external area if you pullup EA- since the code execution automatically continues with external code after internal 8k address. Only point is that the initial 8k space of the external code memory chip will be wasted unless you specifically address decode for space above 8k. And if you do it, that 8k space can as well be used for an 8k data RAM with out any memory clash. You can also keep a portion of your application code soon after the bootloader program in the internal memory and lock it to protect effectively your entire application. This is a great advantage of 8051 architecture.

The interrupt vectors will remain as per the chip specification and you have to make an ljmp to the service routine address where it is stored.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

Since the bootloader is just a little code size in flash memory. Do we still need to use this function:
Code:
((void (code *) (void)) 0x2000) ();       // Call function in VN memory
To jump to 8k address?

Define the initial 8k space can as data RAM, can also keep a portion of my application code soon after the bootloader program and lock it to protect effectively entire application. All this information is very new for me. Thank you very much. I would like to try after i success to read the external code and data.

you have to make an ljmp to the service routine address where it is stored.
What do you mean here? I have set this in my the STARTUP.A51
Code:
                CSEG    AT      0x3000
?C_STARTUP:     LJMP    STARTUP1

I have tested still haven't work. The setting is according to the early address map, intterrupt vector and the LJMP that i show you the previous picture. The external CODE will start at 0x3000.

On the bootloader function is put in the main() function but not in the while(1); Is it correct?

Thank you
 

laktronics

Banned
Joined
Jan 6, 2007
Messages
943
Helped
176
Reputation
352
Reaction score
18
Trophy points
1,298
Activity points
0
Re: 8051_vonneumann

Hi,
I am not referring to your code at all. All that I meant is that from the bootloader area after finishing the loading function, you have to exit the loading process by jumping into the starting address of the application program. This program can start immediately after the bootloader and will seamlessly start running into the external address area after reaching 8k boundary. No need to put any extra jump for this purpose. Also if you are using EEPROM for external code memory, you can probably execute directly from it without copying into RAM area. You have to check, for the CPU clock speed used, the width of PSEN signal is little higher than the required read pulse width of the EEPROM. To be specific, the data from the code memory should be ready within two CPU oscillator cycles from the time the OE- signal goes low. For a 12MHz operation, this is around 160nsec.

Also, this process of using external memory does not in any way affect the interrupt vector locations and as usual you have to ensure that all interrupt subroutines start at their vector address, as usual with a jump instruction.

The usage of the 8k External RAM in the shadow address area of the internal memory is possible if you can ensure that external code memory address is decoded outside this space at 8k and above.

All idiosyncrasies of the specific C language has to be hanled by you only.

Regards,
Laktronics

Note: You need not send additional points for each reply
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

I wonder why i still can't communicate with external memory. When i set the address map and run it as /EA to GND mode. I realize something which is the Interrupt vectors and LJMP address must be a same and must start at either 0x0000 or 0x8000 address only then will work. May i know, Is it possible to start the address at 0x2000 or 0xA000?

At this moment i haven't add the eeprom in the flash memory yet.

I have set the the Interrupt vectors and LJMP address at 0x8000. It work on /EA=0V mode but when testing von-neumann architecture the /EA=5V. On the other hand the internal flash memory after the bootloader i put a jump function. After finished the loading function and exit the loading function will directly jump to 0x8000
The Keil's Disassembly windows shown
Code:
C:0x8000   00      NOP

It look like both side setting is correct but when after loading the hex data to external memory it doesn't work. Where is the miss take? :(

Thank you.

Note: The additional points is the "Helped Me" bottom because of you really helping on me so after I click the bottom the point will load to you already.
 

laktronics

Banned
Joined
Jan 6, 2007
Messages
943
Helped
176
Reputation
352
Reaction score
18
Trophy points
1,298
Activity points
0
Re: 8051_vonneumann

Hi,

When EA- is pulled low, there is no question of communicating with external Code memory, you will always be in the external code memory , and in this case, the ext. memory should be placed starting at 0000h address. Your program will not use the code in the inetrnal memory. On the other hand, when EA- is pulled high, for the first 8k address, no PSEN is generated and the code from the internal memory will be executed. In this case before the execution reaches 8K address, at any point you can jump to external memory address at or after 8k.

I hope you are aware that nowadays there are many 8051 variants available from Companies like Atmel/Philips etc.,which have 64k bytes of internal code memory and supported by builtin bootloader program and free PC software to download your application program into the internal flash. For your application then you need to interface with such chips only required amount of external RAM. So if you are not very particular to realise the circuit using the discrete code memory chips as you are doing now, I would suggest you to have a look at the option of using such modern chips in your application and spend more efforts in making your application program more complete. Just a suggestion for your consideration.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

I have try alot and do alot of testing.
Bellow show is the setting that i tested.
Internal code - LJMP 8003H, External code - Interrupt vector & STARTUP.A51 line-125 = 0x8000
Internal code - LJMP 8003H, External code - Interrupt vector & STARTUP.A51 line-125 = 0x8003
Internal code - LJMP 8000H, External code - Interrupt vector & STARTUP.A51 line-125 = 0x8000

Code:
void runprog(void)
{
#pragma asm
	ljmp 8000H
#pragma endasm
}
Now i'm using ljmp for jump to address 8000h

when EA- is pulled high, for the first 8k address, no PSEN is generated and the code from the internal memory will be executed. In this case before the execution reaches 8K address, at any point you can jump to external memory address at or after 8k.
As you explanation will work and by rite should work but why i still can't solve the problem?

The attached show the setting on compiler. set_bl.pdf is for bootloader internal code. set_xcode.pdf is for external code.

Sorry, I really don't know what can i try already. :(

Thank you
 

laktronics

Banned
Joined
Jan 6, 2007
Messages
943
Helped
176
Reputation
352
Reaction score
18
Trophy points
1,298
Activity points
0
Re: 8051_vonneumann

Hi,
I do not quite understand how you are testing your code and concluding it does not work. What code have you loaded at 0x2000? Let us consider the case of EA- pulled up to Vcc, in this case your Main code should be assembled at 0x0000 in the internal flash memory of C52, where the system control goes following the Reset.

Also a small deviation from what is being discussed, you have not used a MAX232 chip to inetrface your serial interface of your circuit to PC as seen from your schematic, which is essentail.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

Feel very sory need you to spend sometime on me. :(

I do not quite understand how you are testing your code and concluding it does not work.
I have write a simple prints "Hello" message in external code. Just test a simple serial interface on Hyperterminal and try to set the Code range, Xdata range, Start-up address and interrupt vector address.

What code have you loaded at 0x2000?
Code:
void main(void){
   // SerialInit;
   while(1){
   // prints("Hello");
  }
}
Above is the code will be write into SRAM. The code will start loaded at 0x2000. The setting is
Off-chip Code memory:- Start=0x2000 Size=0x5FFF
Off-chip Xdata memory:- Start=0x6000 Size=0x9FFF
Interrupt vectors at address: 0x2000
Un-tick "Use Memory Layout from Target Dialog" at BL51 Locate tab
STARTUP.A51 line-125 CSEG AT 0x2000

in this case your Main code should be assembled at 0x0000 in the internal flash memory of C52
Code:
void main(void){
   // Bootloader;
   // RunExternalProg; LJMP 0x2000
   while(1);
}
Above is the code will be burn into uC. The Interrupt vectors address is 0x0000 and the STARTUP.A51 line-125 CSEG AT 0x0000

where the system control goes following the Reset.
After the RunExternalPrgo function will do nothing already.

Also a small deviation from what is being discussed, you have not used a MAX232 chip to inetrface your serial interface of your circuit to PC as seen from your schematic, which is essentail.
I'm using Proteus simulation to draw the circuit. Without the MAX232 still will working fine. I have wire up and solder it the circuit on testing board. The testing board have MAX232 circuit.

Please can you find where's the problem?

Thank you.
 

laktronics

Banned
Joined
Jan 6, 2007
Messages
943
Helped
176
Reputation
352
Reaction score
18
Trophy points
1,298
Activity points
0
Re: 8051_vonneumann

Hi,
If your communication with PC is working OK, instead of jumping and executing the code from 0x2000, may be after loading the code, you can read the code at 2000 and send it to PC as ASCII and check if the bytes are there as expected at 0x2000. This will verify if your loading part is working OK.
You can even try using your first simple program of writing directly the hand coded code of ljmp 0xE000 changed to 0x2000 in this case.

Hope you have RAMs mounted for address at 0x2000. If SW2 is connected to A15 inverter output, IC U5 ahould be in place.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

may be after loading the code, you can read the code at 2000 and send it to PC as ASCII and check if the bytes are there as expected at 0x2000. This will verify if your loading part is working OK.

Yes, after loading the code before jump to 0x2000 i still can retrace back the data back. The data downloaded in external ram is nice.

You can even try using your first simple program of writing directly the hand coded code of ljmp 0xE000 changed to 0x2000 in this case.
Yes, i have do this function as well. Using hand coded change the address. It is more flexible and easy to do testing.

But another thing is if i loader the code address at 0x0000 or 0x8000. It will working fine. Like other address 0x2000 or 0xE000 wouldn't work. This is /EA to GND condition.
When the address start at 0x8000 is work on /EA to Vcc condition is fine. I use this address and /EA to GND condition, after the bootloader will LJMP 0x8000. It no work. I wonder why :!: :?:

Thank you.
 

laktronics

Banned
Joined
Jan 6, 2007
Messages
943
Helped
176
Reputation
352
Reaction score
18
Trophy points
1,298
Activity points
0
Re: 8051_vonneumann

Hi,
If you are using serial port interrupts, or any other interrupts while executing the code at 0x2000 plus address, the code will not work when EA- is low, unless the lower addresses of the external memory contains the interrupt service routines at their respective vector addresses. So on the fly changing of EA- status can fail in this case.
I do not understand why jump to external codes placed at 0x2000/0xE000 do not work.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating

Help

Advanced Member level 2
Joined
Feb 15, 2005
Messages
617
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,298
Activity points
7,065
Re: 8051_vonneumann

Hi,

Yes, I'm using serial interrupt on both side. Is it this is the root cause? If yes, what can i do?

Thank you.
 

laktronics

Banned
Joined
Jan 6, 2007
Messages
943
Helped
176
Reputation
352
Reaction score
18
Trophy points
1,298
Activity points
0
Re: 8051_vonneumann

Hi,
You can either use only EA- pulled to Vcc and keep your interrupt service routine as it is in the flash memory of the controller, OR

Use an ljmp to 0x2000+ address at the vector addresses at internal flash as well as at the corresponding addresses in the external RAM and keep the service routine at the specified 2000+ address, so that the routine gets executed irrespective of the state of EA-.

Regards,
Laktronics
 

    Help

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top