The relationship between memory, registers, GPIO addresses, and memory
1. As shown in the figure above, 0x0000 0000 represents the first address byte. When the code uses this hexadecimal, the pointer will point to this physical address. For a 4-byte GPIO control unit, the 4-byte physical address is It is called a register. When we write the data configured by the IO port into this register address, the process is as follows:
(1) The cpu converts the code we wrote into machine code
Explanation: The written code was originally written by our keyboard. When a key value is pressed, a level will occur after closing. In the corresponding compiler, it will be converted into characters, such as if (...), Finally, it is burned to the board and turned into an electrical signal (that is, the high and low signal of the transistor).
(2) The cpu runs by fetching the register of the instruction, fetching the instruction, and reading it to the running memory.
Explanation: The running memory here, that is, the ddr connected by the cpu through the address bus, the cpu has a 4G address space, part of which is used for GPIO, utar, spi, special registers, SD, etc., and part is used to connect the running memory ddr, this part of the cpu It is not used by ourselves, but is provided to us in the form of IO ports to connect to DDR, such as computers, but some have built-in DDR in the CPU, which is (RAM), then this part of the IO port is not provided.
(3) Get the data and put it into the GPIO register
Explanation: After putting in the register, through a series of execution commands, the CPU will act on the internal hardware according to the value of the GPIO register, that is, the hardware circuit composed of all transistors related to this GPIO (the chip is composed of hundreds of millions of transistors), For example, the final GPIO frequency, input and output, pull-up and pull-down configuration.