Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Executing code from RAM

Status
Not open for further replies.
Several times I heard this term of executing the code from ram. I want to know how to do it. let us say I have a function f1, I copy the f1 code from flash to known address of ram and shift the pc to that location. Am I correct? But how to know start and end address of function? And how to jump to that ram location?
 
With microcontrollers such PICs and Atmel AVR devices flash and ram (Ram is really registers on these.) occupy different address space. Also there are more bits in flash locations as the instruction codes are more than 8 bits. If you were using something like a Z80 then you can (Provided you allow for the fact that jump or call address would need to be changed.) Note the Z80 chip has no internal memory. (Other than registers.) You just fill the address space with external RAM or ROM to suit your needs. On some computers for example the DEC PDP11 family even I/O devices occupied the same memory space as RAM and ROM.

Les.
 
When executing from ram ( Pic32 can do this ) you have to set up several parameters... A functions address is defined within the executable.... Functions will have " relative " addresses rather than fixed addresses..

If you look into the build of DLL's, each function within the DLL has a calling reference.. If your program were to use any of the functions within the DLL it would need to be defined within the main EXE so it could be paged correctly.

When you tell us that you are working on a "freescale" micro, we cannot know what is going on... Please! When asking these questions, can you mention the type of processor you are referencing.. Then we will be able to help more.

Most micro's cannot run programs from RAM... There needs to be a pointer facility for the PC to access RAM in this fashion..
 
Hi Nigel,
The PDP11 was the only one I was sure had I/O devices in normal memory space without finding data on others. (I worked for DEC from the late 1970s when the PDP11 was common and VAXs started to take over.)
 
For example STM32Fxxx mircos can exectue from RAM. From what I understand you need to do several thing to be able to use it: You need to link the code in such way that the part that is to be executed from RAM will be aware of the address range where it will sit. Also you need some base code that will execute from flash and copy that code into ram.
 
Thank you very much for the replies. Yes I work with freescale but if you tell me the concept I will try to port to my micro. Generally for a bootloader we should run the Flash algorithm for that we should execute the code from Ram, I am not very clear in this, I thought it was common for all the micros and wanted to know about this.
 
Generally for a bootloader we should run the Flash algorithm for that we should execute the code from Ram, I am not very clear in this
Me neither, could you rephrase that sentence so that I can understand what you meant?
 
Just I wanted to know while in the boot loader you have to run the flash algorithm to flash the application memory how to do it. If it is confusing please neglect my previous statement.
 
If I understand correctly what you´re asking, the bootlader will know that at some location in flash memory starts a block of data, and that it is supposed to copy this block to some known RAM location. After this is done it exectues a jump to the start address of the program that is now sitting in the RAM.
 
Hardly most :D

Almost all micro-processors do exactly that, and many micro-controllers do as well - it's mostly the Harvard architecture used in PIC's that prevents it, the more common Von Neumann architecture doesn't usually distinguish.
You know what I mean!!! Virtually all the known micro's ( and I mean controller ) discussed here are Harvard architecture.... Its only when we get to 32 bit where there is a bit of ram to make it worth while!!

Interestingly the PIC32 has a Harvard architecture.... Modified to enabled said feature..
 
You need to be more explicit, particularly after mentions of PDP11's :D
Not really!!! The OP wasn't talking about "ye old computers" He is always talking about free scale micro's... Motorola and Hitachi....
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top