Atmega328 RAM

As I know atmega328 got 2KB Ram I know how Ram works but how exactly it is working
on microcontrollers?

2KB Per second, per exact ms, per function, how?
Give me please an example.

?
I don't follow you. 2KB RAM is 2KB of RAM.
2048 bytes, or 16384 bits, of static RAM, (SRAM), storage for variables. Nothing to do with seconds or milliseconds or functions.
Edit: And that's the 'total' SRAM on the ATMega328P chip.

?
I don't follow you. 2KB RAM is 2KB of RAM.
2048 bytes, or 16384 bits, of static RAM, (SRAM), storage for variables. Nothing to do with seconds or milliseconds or functions.
Edit: And that's the 'total' SRAM on the ATMega328P chip.

Let's take as simple example the computer, a personal computer use Ram, Ram store data for a period of time and after the program is terminated the ram get's free.

How exactly the SRAM works on atmegas?
You said it stores the values of the variables, for example I use in my code approximately 100bytes of data/variables, int/floats/double..etc I execute that 100bytes every second 1000ms, what If i execute
that 100bytes every 100ms or less,
100bytes * 10 = 1000bytes per second, isn't that how it's working, how exactly we store and process the data in SRAM?

I made this topic because I'd like to know how exactly to calculate if my SRAM runs normal or if over loaded.

You don't execute variables, so "1000bytes per second" has no meaning. RAM is just a place to store values until you need them. You execute your program code. SRAM variable memory is completely separate to flash program memory, where the program is stored. The program processes the variables as necessary, according to the code that you write.

I'd like to know how exactly to calculate if my SRAM runs normal or if over loaded.

I have no idea what you mean by SRAM running normally or overloaded.

I have no idea what you mean by SRAM running normally or overloaded.

What is responsible for the data processed / speed and time?

Domino60:
What is responsible for the data processed / speed and time?

I think you're referring to the processor speed, but that's not directly related to how quickly it 'gets through' the variables, but more to do with how many instructions are executed per second.
In a UNO with a 16MHz oscillator and the prescaler set to divide by 1, there are 16 million (machine code) instructions executed per second, (62.5ns per instruction). That does not mean that it processes 16 million bytes of RAM per second.

The only thing that you need to concern yourself with for SRAM is how much of it you're using (in terms of bytes) - if you run out of RAM, bad things happen. Note that the compiler is only able to tell you the memory usage of static and global variables, not memory used by local variables, call stack, or dynamically allocated memory (ex: String class), since that's all that's all that you know at compile time - which is why you can't fill up every bit of ram like you can flash.

It's not related to execution speed - memory access is fast (I think a couple of clock cycles per byte?); if something's slowing things down, it's likely something else.

Then I will cross my fingers and hope everything gonna run ok :smiley:

I got about 100bytes of variables.

Domino60:
Then I will cross my fingers and hope everything gonna run ok :smiley:

I got about 100bytes of variables.

Ha. If you're only using 100 bytes of RAM, I don't think that any finger crossing is necessary.

Ha. If you're only using 100 bytes of RAM, I don't think that any finger crossing is necessary.

100bytes per 100ms or lower, what about the speed ?

Domino60:
100bytes per 100ms or lower,

I don't understand what you're trying to say here. We appear to be going in circles.

what about the speed ?

Yes. (What about the speed?)

In a UNO with a 16MHz oscillator and the prescaler set to divide by 1, there are 16 million (machine code) instructions executed per second, (62.5ns per instruction). That does not mean that it processes 16 million bytes of RAM per second.

I don't understand what you're trying to say here. We appear to be going in circles.

Yes. (What about the speed?)

Sry :smiley: my mind if kinda messy, everything ok

So let's recap
... well I could recap but everything is on a datasheet of the atmega chips :smiley:

I had a misunderstood about the speed of the chip and sram, everything is clear right now.

Domino60:
Sry :smiley: my mind if kinda messy, everything ok

So let's recap
... well I could recap but everything is on a datasheet of the atmega chips :smiley:

I had a misunderstood about the speed of the chip and sram, everything is clear right now.

Oh good, because it's getting late now and I'm tired and easily confused. :smiley: