cancel
Showing results for 
Search instead for 
Did you mean: 

I have a doubt about memory addresses ¿Any expert?

Hi,

First of all, I apologize for my English level, I am not a native speaker. I hope you can understand me :)

Explanation:

1) PHYSICAL WORL: I have searched for information on the electronics behind the memories. In 32 bits microcontrollers, the memory digital circuits have 1 memory address per 4 bytes. In other words, if you would want to store a "char" in the byte 0, you will use the same "real or physical" memory address than if you would want to store other "char" in the byte 1. ( 4 bytes share the same physical memory address )

2) SOFTWARE WORLD: When you store two "char" variables in memory and print their memory address using C language, you can see that they have different memory address. For example:

  • char a = 'a'; // use memory address 0x00000000
  • char b = 'b'; // use memory address 0x00000001

My question is:

¿What is going on?¿Are the memory addresses of the software different from the real ones?¿Are they "fictitious"?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

> In 32 bits microcontrollers, the memory digital circuits have 1 memory address per 4 bytes.

This is not universally so, it depends on the exact processor core.

In particular, with ARM processors, memory is byte-addressable, and processor can access memory byte by byte.

Next to the address bus and the 32-bit data bus, there are extra signals, which indicate, what portion of the bus is valid for write, 8, 16 or all 32 bits. When the ARM processor wants to write a byte through its 32-bit bus, it outputs the byte address to the address bus, outputs the byte to the lower 8 bits of the bus, and then signals "write 8 bits".

JW

View solution in original post

6 REPLIES 6
TDK
Guru

> In 32 bits microcontrollers, the memory digital circuits have 1 memory address per 4 bytes

That's not really true. Certainly not in general. Different memories behave in different ways in terms of their bus size, but this is all taken care of for you at the hardware level. You simply address things as you would in the "software world." Each byte (8 bits) has a different memory address. So storing a 32-bit value will store it across 4 different bytes.

Is there a memory you're particularly interested in? SRAM or Flash maybe?

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

>  I have searched for information on the electronics behind the memories. In 32 bits microcontrollers, the memory digital circuits have 1 memory address per 4 bytes.

Looks like you've searched in a wrong place and found something not related to normal microcontrollers.

This is one of dangers of remote learning. Lot of info, hard to understand what is good and what is crap.

-- pa

> In 32 bits microcontrollers, the memory digital circuits have 1 memory address per 4 bytes.

This is not universally so, it depends on the exact processor core.

In particular, with ARM processors, memory is byte-addressable, and processor can access memory byte by byte.

Next to the address bus and the 32-bit data bus, there are extra signals, which indicate, what portion of the bus is valid for write, 8, 16 or all 32 bits. When the ARM processor wants to write a byte through its 32-bit bus, it outputs the byte address to the address bus, outputs the byte to the lower 8 bits of the bus, and then signals "write 8 bits".

JW

I am interested in SRAM where variables of my C program are store. It is a theoretical interest.

Continuing with the example for a 32 bit microcontroller: I only want to store two "char" variables, a and b (assume memory is empty). Then, the "physical" memory address of the digital circuit doesn't change, right? but the "software" memory address is different from each other.

Am I wrong?

thanks for your answer!

Do you know any source of information where I can see the RTL View of a SRAM memory of 32 bit microcontroller?

Thanks!

What is RTL? Read the data sheets and reference manuals of concrete STM32 microcontrollers. The truth is there.

Note that the "physical" reality is more complex because of caches. Caches deal with even larger memory units called cache lines.

But all this are useless details that can confuse you even more.

-- pa