Flash Memory in Embedded Systems

Flash Memory in Embedded Systems

A trivial mistake that lots of beginners in embedded systems do when they get introduced to Flash and EEPROM is they grab their all mighty pointer and starts trying to write data directly to the Flash and then suddenly discovers that there is nothing happening at all! the data is not written and after a few research they will find out a couple of interesting information about Flash memory technology which are as follows :

Flash must be erased before they are written, Flash must be erased in Blocks or multiple of Blocks ,Flash must be written in pages or multiple of pages.

So of course what will come to your mind so why the hell this thing is not working like RAM and why there is all this limitations? In the following lines I will answer the above questions so you could know what is going on under the hood when you are working with your flash memory.

1-How Flash memory stores and erases data?

Flash memory consists of memory cells where each cell can store one Bit and an array of those cells Represents the data in our memory. Those cells are made of MOSFET transistors which consists of three terminals Gate, Drain ,Source where in our case the MOSFET has an additional gate called the floating gate this gate is the one responsible for storing the data in the cell as follows, When a Positive voltage is applied between the Gate and the Drain (Word line and bit-line) electrons will from source to drain in high intensity and during that process many electrons will jump and stuck in the floating gate causing it to store electrons ! in what is knows as hot-electron injection. The electrons stuck in the floating gate will stay there for very long time until an external force remove them and so you have now stored your data!! .To Erase the memory cell a negative voltage is applied to the word line leading to the repulsion between the negative charges in the gate and the stored electrons in the floating gate so the electron is removed in what is known as Quantum tunneling now you have erased your data!!.the presence of the electrons is sensed and interpreted as a logical zero (Binary 0) and the absence of them is interpreted as logical one( Binary 1).

So now you see we have to erase the memory cells first to remove the electrons in order to be able to re-program them again. for example to store 0xF0 we will need eight memory cells as follows (11110000) to store number 0x0F the cells will have to be as follows (00001111) for this to happen cells have to be erased first so all is free of electrons and seen as (11111111)(0xFF) and then the cells we want to program is applied to the certain voltage that will allow electrons to pass and so the cells will change to (00001111)(0x0F).If erase didn't happen the result will be as follows (00000000)(0x00)which is a mix of the two words and so the data is corrupted!!.

No alt text provided for this image
No alt text provided for this image


2-Why flash must be erased in sectors and written in pages?

Flash memory uses in-circuit wiring to apply the electric field either to the entire chip or to predetermined sections known as sectors. This erases the targeted area of the chip, which can then be rewritten and since erasing is a long process erasing a number of sectors at a time is faster than erasing byte by byte so for the need of speed flash is erased sector by sector and not byte by byte and so the writing operation after the erasing can be done faster.

Mohamed Gebril

Embedded Software Engineer Diagnostics, Bootloader, UDS-ISO-14229. Automotive field

3 年

After reading I can sum up writing to the flash only changes bits to 0s, erasing changing bits to 1s so to write we have to erase the bits to change every bit to 1 then make the 0s by writing ??

回复

要查看或添加评论,请登录

Omar Ehab的更多文章

  • Introduction to Cache Memory

    Introduction to Cache Memory

    Microcontrollers are the heart of every embedded system and in the last decades we have seen an increase in their…

    3 条评论
  • CPU Utilization in Embedded systems

    CPU Utilization in Embedded systems

    An important metric that give an insight about the system performance is the CPU load or utilization. In the following…

    30 条评论
  • Secure Firmware flashing using firmware signing

    Secure Firmware flashing using firmware signing

    The ability to flash a new Firmware to your embedded target using a boot-loader is essential but did you think what if…

    3 条评论
  • Synchronous VS Asynchronous Operations

    Synchronous VS Asynchronous Operations

    One of the concepts that I recognized that lots of people get it wrong is the difference between synchronous and…

    7 条评论
  • Access Synchronization

    Access Synchronization

    Writing Embedded software you will usually encounter the situation where you have to synchronize your tasks either for…

    3 条评论
  • Thread safe and Non-Thread safe Vs Re entrant and Non-Re entrant functions

    Thread safe and Non-Thread safe Vs Re entrant and Non-Re entrant functions

    Multi threading environment could be chaotic if careful design consideration is not taken and one of the most famous…

    4 条评论
  • Interrupt Latency

    Interrupt Latency

    It is known that we use interrupts in embedded software in order to serve asynchronous event almost immediately.so the…

    7 条评论
  • Scheduling analysis and testing using Rate monotonic algorithm with time demand analysis.

    Scheduling analysis and testing using Rate monotonic algorithm with time demand analysis.

    Following up with the article i published before about scheduling and multitasking.In this short tutorial we will see…

  • Functions VS ISR

    Functions VS ISR

    Have you ever thought why interrupt service routines(ISR) in some tool-chains is written in a special format that is…

    2 条评论
  • Introduction to multitasking and scheduling in Embedded systems

    Introduction to multitasking and scheduling in Embedded systems

    This will be a short introduction into multitasking in embedded systems. First what is multitasking? Multitasking is…

    3 条评论

社区洞察

其他会员也浏览了