Why do you need EEROM when there is FLASH in the microcontroller?

This is a piece of answer that was really born for "ending the ignorance".

If you still don't understand it, read it a few more times...

I used to do projects, sometimes I used Flash, sometimes I used EEPROM, which made me a little confused.

Then I searched for some information on the Internet. After reading it, I still couldn't understand it thoroughly. I didn't understand it until I did a lot of projects.

Both Flash and EEPROM are non-volatile memories, that is, after your device is powered off and restarted, the data will be retained. If it is RAM, the data will be lost immediately after power off.

Let's introduce the difference between Flash and EEPROM from several aspects:

1. Reading method

Both Flash and EEPROM adopt random read, which can directly access the data in the memory through the address.

2. Writing method

The writing methods of Flash and EEPROM are different. EEPROM can be written in bytes, while Flash usually needs to be written in blocks.

Also, in Flash, to write a piece of data, you need to erase an entire block first, and then write new data into the block.

3. Erase method

The erasing methods of Flash and EEPROM are different. EEPROM can be erased by byte, while Flash generally needs to be erased by block.

In other words, in Flash, to erase a piece of data, it is usually necessary to erase an entire block first, and then rewrite the data that needs to be kept in the block, which is more troublesome than EEPROM operations.

4. Erase and write speed

The erasing and writing speed of EEPROM is much slower than that of Flash, and the erasing and writing speed will be affected by many factors, including the type of memory used, the type of interface used, the amount of data written and erased, chip temperature, and so on.

5. Storage density

Flash has a higher storage density than EEPROM and can store more data.

6. Lifespan

The lifespan of Flash and EEPROM depends on the way of use, application scenarios and so on.

Generally speaking, the life of EEPROM may be longer, because it can be written and erased in individual byte units, while Flash needs to be erased in whole pages or sectors.

This means that EEPROM can manage memory more flexibly and reduce the number of erasing and writing of memory cells.

However, this does not mean that the life of the EEPROM will be longer in all cases.

7. Price

Flash is cheaper than EEPROM.

8. Different communication interfaces

Many Flash uses SPI protocol interface, and many EEPROMs use IIC protocol interface.

9. Data protection method

Flash具有硬件和软件保护功能,而EEPROM只有软件保护功能。

10.最后总结

Flash更适合存储代码和常量,就是不需要频繁更新、数据量大的场景,比如说音频数据、图片数据、程序等等

EEPROM适合存储需要频繁更新数据、数据量小的场景,比如系统参数配置等等

最后彩蛋时间,最近有粉丝问我怎么提升单片机编程思维和水平

我做了开发10几年,累计做过几十个项目,我针对这些项目共性功能,比如任务创建、管理、队列算法、LED特效、按键扫描等,写了一个标准程序框架。

这个架构,我在2019年也录了教程,我做新项目时,直接套用这个架构去写,效率直接起飞。

不出意外的话,应该是你目前能看到最实用、最硬核、最系统的干货。

现在限时放出来给大家看,后期可能会删,这套架构已申请版权,非学员仅供学习使用

可以点击下方⬇️卡片看文章开头领取

单片机入门到高级开挂学习路径(附教程+工具)

单片机入门到高级开挂学习路径(附教程+工具)

单片机入门到高级开挂学习路径(附教程+工具)

或者可以找「无际单片机」全网同名的。

下面是更多无际原创个人成长经历、行业经验、技术干货

最近在学C语言,非常痛苦,怎么办?

C语言开发单片机为什么大多数都采用全局变量的形式?

单片机怎么实现模块化编程?思维+实例+系统教程(实用程度令人发指)

c语言回调函数的使用及实际作用详解

spi时序图怎么分析,怎么看懂spi时序图

Guess you like

Origin blog.csdn.net/weixin_43982452/article/details/129690150