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.

Rom address and rom location

Status
Not open for further replies.

jidan

Member
Rom and ram both memory are used in micro controller
Rom address- the address where data stored
Ram location - the location where data stored
both things are confuse me does anyone can explain
 
ROM stands for Read Only Memory
RAM stands for Random Access Memory
They are both memory, but will have different speeds, among other things. The exact details for a microcontroller's memory is in it's datasheet. Be sure to read the datasheet for the microcontroller that you are using!
 
I forgot to say that the general rule is that ROM is intended for data that doesn't need to change, and will be there each time the power is on. And RAM is where the data can be changed freely, but disappears when the power goes off.
 
Rom and ram both memory are used in micro controller
Rom address- the address where data stored
Ram location - the location where data stored
both things are confuse me does anyone can explain

Try to think of it more like... ROM is "Code space" and "RAM" is Data space" In the 8051 chips they both start at address 0x000 just confuse you even more.... Any Data stored in ROM are constants ie.. cannot be changed.

Rom address- the address where data stored
This should read... the address where code stored...
 
in
Try to think of it more like... ROM is "Code space" and "RAM" is Data space" In the 8051 chips they both start at address 0x000 just confuse you even more.... Any Data stored in ROM are constants ie.. cannot be changed.


This should read... the address where code stored...
In assembly language we write code that stored in ram and rom
Try to think of it more like... ROM is "Code space" and "RAM" is Data space" In the 8051 chips they both start at address 0x000 just confuse you even more.... Any Data stored in ROM are constants ie.. cannot be changed.


This should read... the address where code stored...
Ok when we write code in assembly language code store in rom memory and program counter increase step . what is the work of ram memory
 
In assembly language we write code that stored in ram and rom
Only on the larger chips.... And really only when using an operating system... I wouldn't use RAM on the smaller chips unless I had a decent File system to get it into memory...

Are you talking about the PC in general?
 
Try to think of it more like... ROM is "Code space" and "RAM" is Data space" In the 8051 chips they both start at address 0x000 just confuse you even more.... Any Data stored in ROM are constants ie.. cannot be changed.


This should read... the address where code stored...


Hi Ian,

how come both ROM and RAM (you're talking on the externals or internals?) start at the same address?

it doesnt make sense.
 
Hi NS.
Thank you very much.

I read on the Harvard Architecture in Wiki,

however, I didn't managed to understand the following.

Both RAM and ROM store data, right? (the ROM may store const variables, and RAM stores the Stack and Dynamic memory).
So the CPU will read data from both during the program execution.

so when the CPU wants to read some data from address 0x0005 from the ROM, how does he "tell" the address and data buses to read it from the ROM and not from the RAM? (or the other way around)
 
so when the CPU wants to read some data from address 0x0005 from the ROM, how does he "tell" the address and data buses to read it from the ROM and not from the RAM? (or the other way around)

The set of instructions which address program memory (ROM) is different from the set of instructions which address data memory (RAM).
 
oh, i see, thanks!!

I indeed read that to read from data memory (RAM), you use MOVX.

it wasn't specified there (in wiki link that NS shared) what is the instruction for ROM
 
Hi Ian,

how come both ROM and RAM (you're talking on the externals or internals?) start at the same address?

it doesnt make sense.

It makes perfect sense. ROM and RAM are not contiguous space. Rather, they are spaces that are physically separate from each other. It's all in HOW we access the memory space and which instructions we use that determines whether we are accessing the internal ROM, internal RAM, external RAM, and the SFR space.

On both 8051 and 8052, directly addressing addresses in the range of 0x80-0xFF always accesses the SFR space. On the 8052, we also have on chip RAM that resides in the 0x80-0xFF range, but we use indirect addressing to access this space.

Example, if we execute -

Code:
                    mov               0x90, #0x55                              ;load value 0x55 to P1 register

This writes the value 0x55 to the P1 SFR. However, if we execute -

Code:
                    mov                R0,#0x90                                 ;load RAM address to R0
                    mov                @R0,#0x55                              ;store value 0x55 to RAM address in R0

This writes the value 0x55 to address 0x90 in internal RAM space as we have indirectly addressed RAM location 0x90 using the R0 register as an address pointer.

Another little trick that you only use if you really know what you're doing is to use the stack pointer along with the push and pop instructions to read/write the memory space from 0x80-0xFF. This works because the stack indirectly addresses the RAM space. On most 8052 applications, I actually dedicate the 0x80-0xFF RAM space to the stack by moving the stack pointer to address 0x7F in my initialization code.

The program counter ONLY accesses internal ROM as this is where the code is stored. We can also read data in code memory by using the MOVC instruction.

*EDIT* - The program counter accesses internal ROM if and ONLY if the !EA pin is tied high. If an instruction in the code calls for an access to program ROM past the internal ROM's address range, it will attempt to access that location on external ROM. However, if the !EA pin is tied low, the program counter will ONLY access external ROM (EA stands for External Access. This pin governs whether the 8051/8052 will execute code from internal or external ROM).

When reading external RAM, we use the MOVX instruction.

Through the use of different instructions and addressing methods to access the different memory spaces, this allows each separate memory space to use the same address ranges.

To summarize -

MOVX is dedicated to external RAM space only
MOV is dedicated to internal RAM space and SFR space only
MOVC is dedicated to internal and external program ROM only
The program counter is dedicated to internal/external ROM space only
 
Last edited:
Note that in Jon's example,
Code:
                    mov               0x90, #0x55                              ;load value 0x55 to P1 register
the value 0x55 is stored in ROM as part of the instruction.

On a pic chip the similar instruction movlw 0x55 also stores the value in ROM.

Mike.
 
Jon

WOW, thank you so much for this great explanation! :)

You explained it so well and it really helped me out understand it!

thank you!

Mike, Ian
Thank you guys for your comments and help as always :)

It makes perfect sense. ROM and RAM are not contiguous space. Rather, they are spaces that are physically separate from each other. It's all in HOW we access the memory space and which instructions we use that determines whether we are accessing the internal ROM, internal RAM, external RAM, and the SFR space.

On both 8051 and 8052, directly addressing addresses in the range of 0x80-0xFF always accesses the SFR space. On the 8052, we also have on chip RAM that resides in the 0x80-0xFF range, but we use indirect addressing to access this space.

Example, if we execute -

Code:
                    mov               0x90, #0x55                              ;load value 0x55 to P1 register

This writes the value 0x55 to the P1 SFR. However, if we execute -

Code:
                    mov                R0,#0x90                                 ;load RAM address to R0
                    mov                @R0,#0x55                              ;store value 0x55 to RAM address in R0

This writes the value 0x55 to address 0x90 in internal RAM space as we have indirectly addressed RAM location 0x90 using the R0 register as an address pointer.

Another little trick that you only use if you really know what you're doing is to use the stack pointer along with the push and pop instructions to read/write the memory space from 0x80-0xFF. This works because the stack indirectly addresses the RAM space. On most 8052 applications, I actually dedicate the 0x80-0xFF RAM space to the stack by moving the stack pointer to address 0x7F in my initialization code.

The program counter ONLY accesses internal ROM as this is where the code is stored. We can also read data in code memory by using the MOVC instruction.

When reading external RAM, we use the MOVX instruction.

Through the use of different instructions and addressing methods to access the different memory spaces, this allows each separate memory space to use the same address ranges.

To summarize -

MOVX is dedicated to external RAM space only
MOV is dedicated to internal RAM space and SFR space only
MOVC is dedicated to internal and external program ROM only
The program counter is dedicated to internal/external ROM space only
 
Hi friends.

I'd appreciate your comments on this matter.

I read about memory shadowing - in which contect of ROM is copied into RAM - in order to read the content faster.

I'm trying to understand the 2 following matters:

1. what type of content is copied from ROM to RAM?
i.e. Program instructions (as x = a + b;) or is it just about const variables, constants, and values of initialized global variables?

2. how can you tell how much of the ROM and which part of it is copied into RAM?

Thank you very much.
 
I use shadowing in a different context.. Shadowing ram can mean a lot of things... A framebuffer for example when working with graphical screens...

The old PC's used to have a BIOS and some PC's used to shadow this by placing the BIOS in ram so the basic IO was quicker... On large processing equipment programs ARE loaded into ram..

On your humble 8051 derivative you have "code space" ROM.... This is referred to as firmware. On a small micro you would never need to shadow the code... But on a pentiumIII you have relocatable memory and code is run from ram anyway...
 
Hi Ian
Thank you very much.

What about copying ROM's content to RAM, in uCs in general - i.e. if it's not done in 8051 (are you sure?) then in other processors as ARM (i'm talking on Embedded, not Computers).

I'm looking to understand these two basics matters:

1. what type of content is copied from ROM to RAM?

2. how can you tell how much of the ROM and which part of it is copied into RAM?
 
What about copying ROM's content to RAM, in uCs in general - i.e. if it's not done in 8051 (are you sure?)

Didn't say that.... You need to see if the architecture will support it... Apparently you can do it but you'll need to map your code to external memory.. The micro will see it as external ROM if you know what I mean.

If you look at the PC ( Program counter ) on small micro's it can only be pointed to the code space allocated and not RAM so it cannot be done in this case... However some small micro's allow external Eprom's, if you exchange it for SRAM, you would need a way to load it at boot time and there would be no facility to write to the device...

I know that ARM and the PIC32 can run code from RAM.... But ask yourself a question... The whole point of micro's is that you are running firmware, so why bother trying.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top