
Today, let's talk about it again, why should we learn microcontrollers?2
Microcontroller, what exactly is learning?
Microcontroller is a control of our I/ O port, no matter what kind of control the microcontroller carries out to the outside world, it is operated through the I/ O port of our microcontroller.
So when we learn a microcontroller, we learn an operation of our I/O, and we accept an external control and feel an external voltage through I/O.
Through the microcontroller to receive an external input signal, that is, through our I / O port to feel the external voltage, a change, we also have to learn.
51 microcontroller, it has a total of P0 P1 P2 P3 these four octopus bidirectional input and output ports.
It should be noted here that the four I/O ports of our microcontroller can be used as bidirectional, that is to say, it can be input or output.
Each port has a memory, output driver, and input buffer.
The four I/O ports of a circuit inside I/O can be used as input and output ports, that is to say, our P0 P1 P2 P3 four ports can be used as inputs and outputs.
In general, learning a control of the I/O port of the microcontroller, as well as some use of some resources inside the microcontroller, such as timer interrupts, this is also a difficult point in learning 51 microcontrollers.
Let's take a look at a structure inside the I/O port of the microcontroller, how is it? There are three kinds here, one is a quasi-bidirectional I/O port, and the other is an open-drain output I/O, and there is a strong push-pull output I/O.
Our 51 microcontrollers usually use these two. The I/O port uses both, one is quasi-bidirectional I/O, and the other is open-drain output I/O.
The open-drain output is for our 51 microcontroller P0 port, 51 microcontroller P0 port, he does not have a pull-up resistor, so if he wants to output a high frequency, he must connect a pull-up externally to output a low frequency or high frequency.
And quasi-bidirectional I/O, he has pulled up a resistor inside so he can directly output high frequency and low frequency, without the need for external addition.
Microcontroller P0 port, he is an open-drain output I/O, P1 P2 P3, it is a quasi-bidirectional I/O, that is to say, it has an internal pull-up resistor. As for the P0 port, it has no pull-up resistor, and he must connect an external pull-up to output.
Let's see how he comes to output high and low frequencies, this is an output port inside our internal microcontroller, suppose we output a high frequency internally, through a reverse device into a low frequency, the reverser is to turn our high frequency into a low frequency, low frequency into a high frequency, such a reverse of a role, and then through the pull-up resistor, the voltage comes over to output a high frequency.
Drain open leakage of an I / O, it does not pull up, if you want to output high frequency, this I / O port it is no output signal, if you want him to output the signal, you must externally connect a pull-up resistor, so that he will output a high frequency, if the output of low frequency, then here is a high frequency, high frequency, then the frequency can output low frequency, but he can not output high frequency, here we should pay attention.
The uncertain signal, through this pull-up resistor to make it achieve high frequency, that is to say, this can play a role in preventing interference, and then, this resistance can play a role in limiting the current, because this pull-up resistor, the current shunt is separated, so he plays a role in limiting the current.
So what about the pull-down, suppose we have this I/O port, which is an output inside us, and the output through an inverter is a pull-up resistor
。
Let's take a look at the pull-up resistor what is the benefit, when the OC gate wants to output a high frequency, the external must add a pull resistor, this OC gate, is the circuit we mentioned earlier a drain open-drain output, so just now we have also said, here must add a pull resistor to output high frequency.
P0 port to connect the pull-up resistor, and then add the pull-up resistance can also increase the driving capacity of our ordinary I/O port, that is, to improve one of our drives, so that our I/O port drive capacity is greater, and then can also play a role in limiting the current, just said, there is also an anti-interference, anti-electromagnetic interference, because this pull-up resistance can put us unsure of that signal, through this resistance, pulled to a high frequency.
Let's look at one of the selection principles for pull-up resistors.
From the perspective of reducing power dissipation, because the larger the resistance, the smaller the current, because according to Ohm's law, it can be known that I is equal to U divided by R, and the larger the resistance, the smaller the current.
From the perspective of ensuring sufficient pin drive capability, it should be necessary to make this pull-up resistance small enough, because the smaller the resistance, the greater the current, also according to this Ohm law.
Open-drain output when too large pull-up resistance will cause the signal to rise along the slower, earlier we talked about the OC gate circuit, this P0 port to add the pull resistance, pull-up resistance, if the choice is too large, it will cause us to rise along become slow,
This is an ascending edge in our ideal situation, and the ascending edge is to change from our electrical frequency to high frequency.
When the pull-up resistance is small, the transformation is relatively fast when he rises when the signal changes, if the pull-up resistance is relatively large, then its signal change, his time is relatively long.
So usually, when we choose a pull-up resistor, it is usually about 4.7K to 10K, and our development version is followed by a 10K resistor to increase one of our driving capabilities, as well as anti-interference these functions.
An introduction to the microcontroller, we will talk about here.
Free to claim! Microcontroller introductory to advanced open-hook learning path (with tutorials + tools)
Since this lesson, everyone has recognized the microcontroller and knows what to learn to learn from the microcontroller. Find me to get the information, open the tutor one-on-one interaction, and open the door to the microcontroller world!