The self-learning of single-chip microcomputer is basically not far from giving up halfway, and systematic learning is the last word

Why does a school exist? You can learn by yourself just by reading a book, so what is the use of a school? Of course, except for some people with strong learning ability and a certain foundation, the rest of the people want to learn by themselves. This road to learn single-chip microcomputer is simply a fantasy. I think I have learned it, but in fact I am just getting started. There is still a long way to go. Come on friends!

In the previous content sharing, I made some simple understandings of the P0 and P2 ports. In this issue, I will continue to share some of the relevant knowledge I understand with you. I hope it will be helpful to you. It is fortunate to meet you who are watching the article in the vast crowd. What is the probability of this, please use your little hands to give me a thumbs up and attention if you are watching, and give me a little touch, thank you.

When it is used as an external memory expansion, it must have an address, that is, each unit of it. For example, it has an address. You must first find this address to find a person, first find their house number, and then find the inside. People, it first finds this address by relying on the P0 port as the low eight-bit address, the address bus of the external memory expansion microcontroller is 16 bits, the high eight bits are processed by the P2 port, and the high eight bits of the address together form a 16-bit address bus, once the two address buses are sent out, it may find the address unit. After finding the address unit, the address will be latched by the latch signal, and the address lock of the P0 port will be stored. The P0 port actually It is time-division multiplexing, which is not only used as the eighth bit of the address bus, but also used as a data bus.

When it is used as an address bus and a data bus, it is time-sharing multiplexing. At this time, it will only play a role when it is used as an external memory expansion. In normal times, if the external memory is not expanded, the P0 port can be used as a common I/O port. When it is used as a common I/O port, it should be noted that a pull-up resistor must be added externally, otherwise the level state is uncertain. This is a structure of the P0 port.

The structure of the P2 port and the structure of the P0 port also have an additional multiplexer switch, but its output stage is different. The output pole has an internal pull-up resistor and an additional NOT gate, which is not the same as the P1 port. Too the same, it also has two functions as a common I/O port and as the upper eight bits of the address bus. When it is used as a common I/O port, the first control terminal is 0, and the switch is hit below and connected to the internal bus. Once the level is disconnected, it will be connected to VC through the pull-up resistor, and the external pin will present a high level. When 0 is written on the internal bus, after the switch, one end of the NOT gate is 1. The FET will conduct Pass through, the external pin must present a low level.

When doing the input function, it is still necessary to write 1 to the internal bus first, otherwise the input channel will read wrong when reading the state of the external level. It will make an error. In order to avoid this situation, write 1 on the internal bus first. The purpose is to make the FET in a disconnected state, so that the level of the external pin can really enter from the input channel. When it is high, the internal longitudinal reading is 1. When the external is connected to D, the reading on the internal bus is 0. At this time, the level reading will not be wrong.

At the same time, it also has the function of reading the latch. The P2 port can be used as the upper eight bits of the address bus. When it is used as the address bus, the control terminal must be 1 and the switch must be hit above. At this time, the structure is the same as that of the P0 port. Now, because the switch is only related to the address bus, so at this time, the P2 port is used as the address bus. When the output is high, it outputs 1. When the non-gate is 0, it is disconnected, and the external is high. At the same time, if the address bus is written to be 0, the same reason the switch is still hit above, the FET is turned on, and the external pin presents a high level and a low level, so as to select an external device.

The P2 port is used as the high 8-bit 16 lines, and the address range can be selected to 0000H or FFFH. When it is used as a memory expansion, the maximum can be extended to 64K. This is the reason. This is the structure of the P2 port. You can find it appropriately. This book or this electronic textbook will briefly analyze the internal structure and carefully understand its internal structure, so as to understand a specific function of it. In this way, when you use other performance microcontrollers in the future, especially Only when it is a high-performance single-chip microcomputer can the I/O port of the single-chip microcomputer be used flexibly. If you think it is troublesome to read books, you can also contact through the homepage introduction or private chat, and I can send you some related tutorials for your reference.

Finally, a brief summary is made on the P0 port and the P2 port.

The P0 port has two functions, one is as a common I/O port, and the other is as a time-sharing multiplexing of the address and data bus. When used as a common I/O port, it can realize output, read pins and read latches There are three functions. When the P0 port is used as a quasi-bidirectional I/O port, you need to pay attention, that is to say, write 1 first when it is used as an input, and connect an external pull-up resistor when it is used as a general-purpose I/O port. Because it does not have a pull-up resistor inside, a FET is pulled up internally. When using ordinary I/O ports, the internal FET is in a cut-off state, which will cause the lower-end FET to leak. The state of extremely open circuit, so an external pull-up resistor should be added to make it in a certain level state. Another function is to use as a time-division multiplexing of the address and data bus, which can realize the output and input of the address and data bus. Two functions, no pull-up resistor required.

The P2 port also has two functions. One is when it is used as a common I/O port, it can realize the output read pins and read latches of the common I/O port. It should be noted that when it is used as a common I/O port input function When it is used as a general-purpose I/O port, it needs to write 1 first. When it is used as a general-purpose I/O port, there is an external internal pull-up resistor, so no external pull-up resistor is required. The internal structure and functions of several I/O ports, I hope to be helpful to everyone, to be able to understand the structure of the I/O ports clearly, and to be able to use the I/O ports flexibly.

If you like it, please help to collect it and give it a like. The content of the above article only represents personal opinions. Friends who are interested in single-chip microcomputers and want to learn about single-chip microcomputers systematically and quickly, you can privately message me, and I can send some information to you as a reference for learning. Friends who have questions can also comment in the comment area, or privately message me, try to help you solve the problems raised by your friends, thank you, the content of the above article has nothing to do with the content of the article

Guess you like

Origin blog.csdn.net/m0_66707146/article/details/123422679