In order to figure out How the MCU Memory Works, it is necessary to learn its struture, MCU Memory is where the data and program is stored. It uses the high and low electrical level to store the data and program, as a result of that, it stores the high and low electrical levels, not the number of 1,2,3,4 we are used to think of.
There is such a memory in the MCU. This is a schematic diagram of a memory: a memory is like a small drawer, and a small drawer has eight small lattices. Each small lattice is used to store the “charge”. The wires connected to it are transmitted in or discharging. As for how the charge is stored in the small grid, we don’t have to worry about it. You can imagine the wire as a water pipe. The charge in the small lattice is like water and each small drawer in memory is a place to put data, which we call a “unit.”
With such a structure, we can start storing data. We want to put in a data of 12, which is 00001100. We just need to fill the second and third small grids with charges, and put no charge on the other small grids.
If a MCU memory has many cells, and the wires are connected in parallel. When the charge is placed, the charge is placed in all the cells, and when the charge is released, the charge in each cell is discharged, so that no matter how many cells in the memory, only the same number can be placed.
This is of course not what we want. Therefore, to make a slight change in the structure, on each unit. There is a control line, I want to put the data into which unit, give a signal to the control line of this unit, this control line will open the switch, so that the charge can flow freely, and there is no signal on the other unit control line, Therefore, the switch does not open and will not be affected. In this way, as long as the control lines of different units are controlled, different data can be written to each unit. Similarly, if data is to be taken from a unit, only the corresponding cell is opened. The control switch will do.