Arduino上的不同类型的内存|SRAM, EEPROM, Flash

在本教程中,我们将了解计算机内存,其操作和类型的基础知识。然后,我们将专注于Arduino,并了解Arduino上的不同类型的内存类型,例如Flash,Eeprom,Ram,它们的大小和目的。

What is Computer Memory?

Computers are designed and developed to perform various engineering, mathematical, educational and entertainment tasks at very high speed and with great accuracy. All these complex tasks can be boiled down to just three basic operations:

  • 在一些输入设备的帮助下接受数据。
  • 分析和处理数据。
  • Produce the result (data) with the help of some output devices.

For the processor to do these operations seamlessly, it needs to store the input data, hold the intermediate results and also store the output data (results) at some place. This is called Memory.

A Computer Memory is an electronic device that stores data and instructions either permanently or temporarily. Irrespective of the size and application i.e., it can be a huge storage server or a simple microcontroller based embedded system, all computer systems require memory.

Memory Representation

我们知道数字电子产品仅处理两个数字1和0。这用于表示信号的电压水平。例如,在5V逻辑级系统中,“ 1”表示5V和“ 0”表示0V。

So, the state of a signal can be either ‘1’ or ‘0’ at any given time. This is known a Bit, which is the smallest unit of data in Digital World. By combining 8 of these bits, we get a Byte, which can 28= 256个不同的位模式。

下面列出了两个通用信息单位:

位:最小的数据单元。它在两个可能的值“ 1”或“ 0”的帮助下代表逻辑状态。

字节:一组8位称为字节。数据字节可以在00000000和111111之间具有任何二进制值。

Basic Memory Operations

只有两个基本可以在内存上执行。他们是读写的。内存上的典型读取操作需要一个地址作为输入,并在该位置返回数据。

在典型的写操作的情况下,它需要一个必须存储数据和实际数据本身的地址。

内存类型

计算机系统上的所有不同记忆都可以分为两种类型的内存。他们是公羊和rom。

内存or Random-Access Memory is used to store temporary data. In Microprocessor based systems, the operating system, applications and other data is loaded on to the RAM so that it can be quickly accessed by the processor.

In case of Microcontroller based systems, RAM is used to store temporary data.

ROM或仅读取的内存更多是存储应用程序代码或固件的永久存储。

在阿尔杜诺岛上的记忆类型

Volatile vs. Non-Volatile

Another important classification of Memories is based on the power dependency. Memories like RAM store data as long as power is supplied and once they are powered down, the data in them is gone. This type of memory is known as Volatile Memory.

On the other hand, memories like ROM are called Non-Volatile Memory as the data in them is independent of power i.e., they retain the data even when power is removed.

Different Types of Memory on Arduino

既然我们已经看到了有关计算机内存和不同类型的内存的一点,那么现在让我们继续了解Arduino上的不同类型的内存。

像任何计算机系统一样,即使是Arduino也有两个基本记忆,即RAM和ROM。但是有趣的是,它们的组织方式以及大小。

Basically, there are three types of Memory on Arduino Boards like UNO, Mega 2560 or Nano. They are:

  • 闪光
  • 内存
  • EEPROM

The RAM in Arduino is like any other RAM, used to store temporary data and is also Volatile. Flash and EEPROM are two types of ROM Memory used to store application code and small data. They are non-volatile in nature.

Let us see about these three types of memory on Arduino individually and also compare their sizes on different Arduino Boards.

笔记:Technically speaking, all these memories are part of the Microcontrollers (like ATmega328P or ATmega 2560) on the Arduino Boards (like UNO, Nano, Mega2560).

闪光

The Flash Memory is also called Flash ROM. In Arduino, the Flash stores the application code to be run. After we write an Arduino Sketch, like a Blinky for example, we simply click the Upload button in the Arduino IDE to run the blinky program.

In the background, this will compile the sketch and produce a binary file and stores the binary file in to the Flash of Arduino. Upon reset, the Arduino will read the instructions stored in the flash memory and preform the necessary operation.

下表比较了一些流行的Arduino板上的闪存量。

Arduino董事会

微控制器 Size of Flash Memory
Arduino UNO ATmega328P

32 KB

ArduinoNano

ATmega328P 32 KB
Arduino Mega 2560 ATmega 2560

256 KB

ArduinoMicro

Atmega32U4 32 KB
Arduino Leonardo Atmega32U4

32 KB

一些标准t of this Flash Memory is actually used by Bootloader, which is responsible for storing the binary file in to the flash through serial interface.

EEPROM

The next type of memory on Arduino is EEPROM. EEPROM is short for Electrically Erasable Programmable Read Only Memory.

Actually, the Flash Memory mentioned above is also a type of EEPROM. The main difference is EEPROM can be erased at a Byte level whereas a Flash can be erased at a Block Level.

EEPROMin Arduino is usually used to store small amount of data like states of input or output devices so they it can be retained even if the Arduino loses power. I made a dedicated tutorial on Arduino EEPROM (both internal and external).

For more information on Arduino’s Internal EEPROM visit “Arduino EEPRPM Tutorial”. If you are interested in interfacing an I2基于C的外部EEPROM IC,例如ARDUINO,然后访问“ Arduino AT24C256 EEPROM教程”。

回到Arduino上的Eeprom,通常很小,只有很小的字节。下表显示了不同Arduino板上EEPROM的大小。

Arduino董事会

微控制器 EEPROM的大小
Arduino UNO ATmega328P

1 kb

ArduinoNano

ATmega328P 1 kb
Arduino Mega 2560 ATmega 2560

4 KB

ArduinoMicro

Atmega32U4 1 kb
Arduino Leonardo Atmega32U4

1 kb

内存

Arduino中的RAM实际上称为SRAM或静态随机访问存储器,一种使用触发器存储1位数据的RAM类型。另一种类型的RAM称为DRAM或动态随机访问存储器,该内存使用电容器存储数据。

在Arduino中,SRAM存储临时数据或运行时间数据(由函数创建的变量,中断)。Arduino中的SRAM实际上分为几个部分。他们是:

  • Text
  • 数据
  • BSS
  • Heap

“文本”段包含从闪存加载的任何指令。“数据”部分包含草图中初始化的变量。“ BSS”段包含任何非初始化的数据(并将其初始化为0)。

最后,堆栈和堆。堆栈是RAM的那部分,该部分实际上在执行代码时实际上存储了函数和中断的数据。如果在运行时间创建任何变量,则将它们存储在堆中。

The following table describes the amount of SRAM available in different Arduino Boards.

Arduino董事会

微控制器 Size of RAM
Arduino UNO ATmega328P

2 KB

ArduinoNano

ATmega328P 2 KB
Arduino Mega 2560 ATmega 2560

8 KB

ArduinoMicro

Atmega32U4 2.5 kb
Arduino Leonardo Atmega32U4

2.5 kb

结论

在本教程中,您了解了计算机内存,计算机内存的类型,挥发性和非易失性记忆以及Arduino板上不同类型的内存类型。

发表评论

Your email address will not be published.

电子产品hub Favicon
<\/i>","library":""}}" data-widget_type="nav-menu.default">
Baidu